feat: complete 2.0.7.12 platform overhaul
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -8,6 +9,7 @@ import (
|
||||
"ymhut-box/server/unified-management/internal/config"
|
||||
"ymhut-box/server/unified-management/internal/health"
|
||||
"ymhut-box/server/unified-management/internal/notices"
|
||||
"ymhut-box/server/unified-management/internal/reference"
|
||||
)
|
||||
|
||||
func (r *router) handleClientBootstrap(w http.ResponseWriter, req *http.Request) {
|
||||
@@ -34,6 +36,7 @@ func (r *router) handleClientBootstrap(w http.ResponseWriter, req *http.Request)
|
||||
"releaseManifest": true,
|
||||
"endpointCalls": true,
|
||||
"legacyJson": true,
|
||||
"referenceData": true,
|
||||
},
|
||||
"endpoints": map[string]string{
|
||||
"releases": "/api/client/releases",
|
||||
@@ -41,6 +44,7 @@ func (r *router) handleClientBootstrap(w http.ResponseWriter, req *http.Request)
|
||||
"clientEndpoints": "/api/client/endpoints",
|
||||
"endpointCalls": "/api/client/endpoint-calls",
|
||||
"notices": "/api/client/notices",
|
||||
"referenceData": "/api/client/reference-data/:kind",
|
||||
"feedback": "/",
|
||||
},
|
||||
"cache": map[string]int{
|
||||
@@ -48,19 +52,44 @@ func (r *router) handleClientBootstrap(w http.ResponseWriter, req *http.Request)
|
||||
"releasesSeconds": 300,
|
||||
"sourcesSeconds": 600,
|
||||
"healthSeconds": 300,
|
||||
"referenceSeconds": 86400,
|
||||
},
|
||||
"legacyRoutes": []string{"/update-info.json", "/update-info", "/api/update-info", "/api/releases", "/tool-status.json", "/media-types.json", "/modules.json", "/downloads/:filename"},
|
||||
"release": release,
|
||||
"sources": sourceCatalog,
|
||||
"feedback": map[string]any{"submit": "/", "status": "/?api=status&code=:code"},
|
||||
"branding": config.SafeBranding(r.effectiveBranding()),
|
||||
"health": health.Snapshot(r.cfg, r.store),
|
||||
"notices": publicNotices,
|
||||
"legacyRoutes": []string{"/update-info.json", "/update-info", "/api/update-info", "/api/releases", "/tool-status.json", "/media-types.json", "/modules.json", "/downloads/:filename"},
|
||||
"release": release,
|
||||
"sources": sourceCatalog,
|
||||
"feedback": map[string]any{"submit": "/", "status": "/?api=status&code=:code"},
|
||||
"branding": config.SafeBranding(r.effectiveBranding()),
|
||||
"health": health.Snapshot(r.cfg, r.store),
|
||||
"notices": publicNotices,
|
||||
"referenceData": r.referenceData.Descriptors(),
|
||||
}
|
||||
})
|
||||
writePublicSnapshot(w, req, snapshot)
|
||||
}
|
||||
|
||||
func (r *router) handleClientReferenceData(w http.ResponseWriter, req *http.Request) {
|
||||
if req.Method != http.MethodGet && req.Method != http.MethodHead {
|
||||
writeError(w, http.StatusMethodNotAllowed, "METHOD_NOT_ALLOWED", errors.New("GET required"))
|
||||
return
|
||||
}
|
||||
kind := strings.TrimPrefix(cleanPath(req.URL.Path), "/api/client/reference-data/")
|
||||
if kind == "" || strings.Contains(kind, "/") {
|
||||
http.NotFound(w, req)
|
||||
return
|
||||
}
|
||||
payload, err := r.referenceData.Read(kind)
|
||||
if errors.Is(err, reference.ErrNotFound) {
|
||||
writeError(w, http.StatusNotFound, "REFERENCE_DATA_NOT_FOUND", err)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, "REFERENCE_DATA_FAILED", err)
|
||||
return
|
||||
}
|
||||
snapshot := r.publicSnapshots.Get("reference-data|"+kind, func(_ time.Time) any { return payload })
|
||||
writePublicSnapshot(w, req, snapshot)
|
||||
}
|
||||
|
||||
func (r *router) handleClientSources(w http.ResponseWriter, req *http.Request) {
|
||||
baseURL := requestBaseURL(req, r.cfg.BaseURL)
|
||||
snapshot := r.publicSnapshots.Get("sources|"+baseURL, func(_ time.Time) any {
|
||||
|
||||
Reference in New Issue
Block a user