From ef7e9b1a53814ea00be2448a4a78225214ff3d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Tue, 14 Jun 2022 22:34:51 +0000 Subject: [PATCH] move metrics to /metrics. --- internal/api/router.go | 7 ------- internal/http/manager.go | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/internal/api/router.go b/internal/api/router.go index 96a174dd..c7d171b9 100644 --- a/internal/api/router.go +++ b/internal/api/router.go @@ -5,8 +5,6 @@ import ( "errors" "net/http" - "github.com/prometheus/client_golang/prometheus/promhttp" - "gitlab.com/demodesk/neko/server/internal/api/members" "gitlab.com/demodesk/neko/server/internal/api/room" "gitlab.com/demodesk/neko/server/pkg/auth" @@ -64,11 +62,6 @@ func (api *ApiManagerCtx) Route(r types.Router) { _, err := w.Write([]byte("true")) return err }) - - r.Get("/metrics", func(w http.ResponseWriter, r *http.Request) error { - promhttp.Handler().ServeHTTP(w, r) - return nil - }) } func (api *ApiManagerCtx) Authenticate(w http.ResponseWriter, r *http.Request) (context.Context, error) { diff --git a/internal/http/manager.go b/internal/http/manager.go index 0ead57ef..d81f695e 100644 --- a/internal/http/manager.go +++ b/internal/http/manager.go @@ -6,6 +6,7 @@ import ( "os" "github.com/go-chi/cors" + "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/rs/zerolog" "github.com/rs/zerolog/log" @@ -41,6 +42,11 @@ func New(WebSocketManager types.WebSocketManager, ApiManager types.ApiManager, c return config.AllowOrigin(r.Header.Get("Origin")) })) + router.Get("/metrics", func(w http.ResponseWriter, r *http.Request) error { + promhttp.Handler().ServeHTTP(w, r) + return nil + }) + if config.Static != "" { fs := http.FileServer(http.Dir(config.Static)) router.Get("/*", func(w http.ResponseWriter, r *http.Request) error {