v0.1.27: страница-описание сервиса на корне / (дизайн Nubes) + /static

This commit is contained in:
“Naeel”
2026-08-14 09:05:16 +04:00
parent 5437b9a918
commit af656fe8f5
7 changed files with 357 additions and 4 deletions
+13 -1
View File
@@ -39,6 +39,9 @@ func New(tenantStore *tenant.TenantStore, adminToken string) http.Handler {
// /health — публичный, без auth
r.HandleFunc("/health", health).Methods("GET")
// /static — логотип, favicon для публичных страниц
r.PathPrefix("/static").Handler(ui.StaticHandler()).Methods("GET")
// /metrics — Prometheus endpoint для Victoria Metrics scrape
r.Handle("/metrics", promhttp.Handler()).Methods("GET")
@@ -58,7 +61,16 @@ func New(tenantStore *tenant.TenantStore, adminToken string) http.Handler {
// r.NewRoute().Subrouter() с Use() некорректно работает в gorilla/mux v1.8.0
// при пустом prefix — ответы теряются. Поэтому используем явную обёртку.
sqsAuth := auth.AuthMiddleware(tenantStore)
r.Handle("/", sqsAuth(http.HandlerFunc(actionHandler))).Methods("GET", "POST")
// Корень: GET без Action — публичная страница-описание сервиса;
// всё остальное (POST, или GET с Action/X-Amz-Target) — SQS API за tenant auth.
rootHandler := func(w http.ResponseWriter, req *http.Request) {
if req.Method == http.MethodGet && extractAction(req) == "" {
ui.InfoHandler(models.Version).ServeHTTP(w, req)
return
}
sqsAuth(http.HandlerFunc(actionHandler)).ServeHTTP(w, req)
}
r.HandleFunc("/", rootHandler).Methods("GET", "POST")
r.Handle("/{account}", sqsAuth(http.HandlerFunc(actionHandler))).Methods("GET", "POST")
r.Handle("/queue/{queueName}", sqsAuth(http.HandlerFunc(actionHandler))).Methods("GET", "POST")
r.Handle("/{account}/{queueName}", sqsAuth(http.HandlerFunc(actionHandler))).Methods("GET", "POST")