platform: modularize api/gui, add docs-tests-web foundation, and refresh root config

This commit is contained in:
beckline
2026-03-26 22:40:54 +03:00
parent 0e2d7f61ea
commit 6a56d734c2
562 changed files with 70151 additions and 16423 deletions

View File

@@ -0,0 +1,60 @@
package app
import (
"net/http"
"strings"
"time"
)
func handleTransportClientHealthAction(w http.ResponseWriter, r *http.Request, id string) {
if r.Method != http.MethodGet {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}
transportMu.Lock()
st := loadTransportClientsState()
transportMu.Unlock()
idx := findTransportClientIndex(st.Items, id)
if idx < 0 {
writeJSON(w, http.StatusNotFound, TransportClientHealthResponse{
OK: false,
Message: "not found",
Code: "TRANSPORT_CLIENT_NOT_FOUND",
})
return
}
it := st.Items[idx]
now := time.Now().UTC()
backend := selectTransportBackend(it)
probe := backend.Health(it)
snapshot := applyTransportHealthProbeSnapshot(it, backend.ID(), probe, now)
resp := buildTransportHealthResponse(snapshot, now)
if !probe.OK && strings.TrimSpace(probe.Code) != "" {
resp.Code = probe.Code
if strings.TrimSpace(probe.Message) != "" {
resp.Message = probe.Message
}
}
writeJSON(w, http.StatusOK, resp)
}
func handleTransportClientMetricsAction(w http.ResponseWriter, r *http.Request, id string) {
if r.Method != http.MethodGet {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}
transportMu.Lock()
st := loadTransportClientsState()
transportMu.Unlock()
idx := findTransportClientIndex(st.Items, id)
if idx < 0 {
writeJSON(w, http.StatusNotFound, TransportClientMetricsResponse{
OK: false,
Message: "not found",
Code: "TRANSPORT_CLIENT_NOT_FOUND",
})
return
}
it := st.Items[idx]
writeJSON(w, http.StatusOK, buildTransportMetricsResponse(it, time.Now().UTC()))
}