fix(metrics): 在主路由中注册 /metrics 端点
Some checks failed
CI / Build & Test (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / Docker Build (push) Has been cancelled
CI / Release (push) Has been cancelled

- 添加 metrics 包导入
- 在主 handler 中注册 GET /metrics 路由
This commit is contained in:
phamnazage-jpg
2026-06-02 07:22:01 +08:00
parent 278991bc9d
commit 5e3bd44e96

View File

@@ -24,6 +24,7 @@ import (
"sub2api-cn-relay-manager/internal/store/sqlite"
"sub2api-cn-relay-manager/internal/access"
"sub2api-cn-relay-manager/internal/metrics"
)
// 版本信息变量,在构建时通过 -ldflags 注入
@@ -336,6 +337,7 @@ func NewAPIHandlerWithAuth(adminAuth AdminAuthConfig, actions ActionSet) http.Ha
mux := http.NewServeMux()
mux.HandleFunc("GET /healthz", healthz)
mux.HandleFunc("GET /version", handleVersion)
mux.Handle("GET /metrics", metrics.Handler())
mux.HandleFunc("GET /api/admin/session", func(w http.ResponseWriter, r *http.Request) {
handleAdminSessionState(w, r, adminAuth)
})