diff --git a/Makefile b/Makefile index 501cd6f..64abb83 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # Registry: Docker Hub (naeel/shared-sqs) IMAGE_REPO=naeel/shared-sqs -VERSION=v0.1.30 +VERSION=v0.1.31 LDFLAGS=-X shared-sqs/app/models.Version=$(VERSION) BINARY=shared-sqs diff --git a/app/router/router.go b/app/router/router.go index 2c63d9b..78f1323 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -45,6 +45,15 @@ func New(tenantStore *tenant.TenantStore, adminToken string) http.Handler { // /metrics — Prometheus endpoint для Victoria Metrics scrape r.Handle("/metrics", promhttp.Handler()).Methods("GET") + // Админ-консоль — статика. Регистрируем ДО admin subrouter, + // иначе PathPrefix("/admin") с bearer-auth перехватит GET /admin. + r.HandleFunc("/admin", func(w http.ResponseWriter, req *http.Request) { + ui.AdminHandler(models.Version).ServeHTTP(w, req) + }).Methods("GET") + r.HandleFunc("/admin/", func(w http.ResponseWriter, req *http.Request) { + ui.AdminHandler(models.Version).ServeHTTP(w, req) + }).Methods("GET") + // Admin API — Bearer token auth, регистрируется через AdminHandler adminHandler := admin.NewHandler(tenantStore, adminToken) adminHandler.RegisterRoutes(r) diff --git a/app/ui/admin.html b/app/ui/admin.html new file mode 100644 index 0000000..0b87aa0 --- /dev/null +++ b/app/ui/admin.html @@ -0,0 +1,409 @@ + + + + + + +SQS Admin — Nubes + + + + + +
+
+ Nubes +

SQS Admin

+
+ + +
+
+ +
+
+ + + + + + + + + + diff --git a/app/ui/embed.go b/app/ui/embed.go index 3777766..e4351cb 100644 --- a/app/ui/embed.go +++ b/app/ui/embed.go @@ -10,7 +10,7 @@ import ( "strings" ) -//go:embed index.html info.html static +//go:embed index.html info.html admin.html static var content embed.FS // Handler — возвращает http.Handler, раздающий встроенный index.html @@ -32,6 +32,20 @@ func InfoHandler(version string) http.Handler { }) } +// AdminHandler — админская консоль (GET /admin) с подстановкой версии +func AdminHandler(version string) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + body, err := content.ReadFile("admin.html") + if err != nil { + http.Error(w, "admin page unavailable", http.StatusInternalServerError) + return + } + html := strings.ReplaceAll(string(body), "{{VERSION}}", version) + w.Header().Set("Content-Type", "text/html; charset=utf-8") + _, _ = w.Write([]byte(html)) + }) +} + // StaticHandler — раздаёт /static/* (логотип, favicon) для публичных страниц func StaticHandler() http.Handler { sub, err := fs.Sub(content, "static") diff --git a/app/ui/index.html b/app/ui/index.html index a1b1107..79f1c98 100644 --- a/app/ui/index.html +++ b/app/ui/index.html @@ -374,17 +374,17 @@ td.msg-expand { padding: 0 !important; border-bottom: 1px solid var(--border); }

Для демо используйте token: demo-ui-shared-sqs-ngcloud-2026.
- Для личного tenant-а используйте API token из панели Nubes. + Для личного аккаунта используйте API token из панели Nubes.

Информация о сервисе
Endpoint: https://sqs.containerk8s.dev.nubes.ru
Health: GET /health · Метрики: GET /metrics
SQS API: POST / (AWS Signature V4, регион us-east-1)
-
Admin API: POST /admin/tenants (Bearer token)
+
Админ-консоль: /admin (вход по admin-токену)
Realm: iot-naeel · Persistence: Managed Redis
Версия:
-
Образ: naeel/shared-sqs:v0.1.29
+
Образ: naeel/shared-sqs:v0.1.31
Статус: тестирование
@@ -413,7 +413,7 @@ td.msg-expand { padding: 0 !important; border-bottom: 1px solid var(--border); }