Skip to content

Commit 4a4cfd0

Browse files
authored
fix: Use dedicated HTTP muxers for health and metrics endpoints (#162)
Signed-off-by: jannfis <[email protected]>
1 parent 457b52f commit 4a4cfd0

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

pkg/health/health.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import (
1212
func StartHealthServer(port int) chan error {
1313
errCh := make(chan error)
1414
go func() {
15-
http.HandleFunc("/healthz", HealthProbe)
16-
errCh <- http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
15+
sm := http.NewServeMux()
16+
sm.HandleFunc("/healthz", HealthProbe)
17+
errCh <- http.ListenAndServe(fmt.Sprintf(":%d", port), sm)
1718
}()
1819
return errCh
1920
}

pkg/metrics/metrics.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ type ClientMetrics struct {
4040
func StartMetricsServer(port int) chan error {
4141
errCh := make(chan error)
4242
go func() {
43-
http.Handle("/metrics", promhttp.Handler())
44-
errCh <- http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
43+
sm := http.NewServeMux()
44+
sm.Handle("/metrics", promhttp.Handler())
45+
errCh <- http.ListenAndServe(fmt.Sprintf(":%d", port), sm)
4546
}()
4647
return errCh
4748
}

0 commit comments

Comments
 (0)