move metrics to /metrics.

This commit is contained in:
Miroslav Šedivý 2022-06-14 22:34:51 +00:00
parent 6deaa64884
commit ef7e9b1a53
2 changed files with 6 additions and 7 deletions

View File

@ -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) {

View File

@ -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 {