diff --git a/internal/server.go b/internal/server.go index cb0f503..5fdfdc5 100644 --- a/internal/server.go +++ b/internal/server.go @@ -93,11 +93,13 @@ func (s *server) metricsHandler(w http.ResponseWriter, _ *http.Request) { // serveMetrics http server func (s *server) serveMetrics(port int) { - http.HandleFunc("/metrics", s.metricsHandler) + mux := http.NewServeMux() + + mux.HandleFunc("/metrics", s.metricsHandler) log.Println(fmt.Sprintf("metrics server started on %d ...", port)) - if err := http.ListenAndServe(fmt.Sprintf(":%d", port), nil); err != nil { + if err := http.ListenAndServe(fmt.Sprintf(":%d", port), mux); err != nil { log.Println(fmt.Errorf("failed to start metrics server error=%w", err)) } } diff --git a/test/server_test.go b/test/server_test.go index 7e2bfcb..a442174 100644 --- a/test/server_test.go +++ b/test/server_test.go @@ -44,7 +44,7 @@ func TestServer(t *testing.T) { // TestAuthServer // testing stallion server with auth. func TestAuthServer(t *testing.T) { - // creating a stallion server on port 6001 with user and pass + // creating a stallion server on port 6002 with user and pass go func() { if err := stallion.NewServer(":6002", 6003, "root", "password"); err != nil { t.Errorf("server failed to start: %v", err)