refactor(server/v2/telemetry): swap redirects (#22520)

This commit is contained in:
Julien Robert 2024-11-13 18:39:44 +04:00 committed by GitHub
parent 276a667d77
commit e74799e1c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -67,10 +67,10 @@ func (s *Server[T]) Start(ctx context.Context) error {
}
mux := http.NewServeMux()
mux.HandleFunc("/", s.metricsHandler)
// keeping /metrics for backwards compatibility
mux.HandleFunc("/metrics", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/", http.StatusMovedPermanently)
// /metrics is the default standard path for Prometheus metrics.
mux.HandleFunc("/metrics", s.metricsHandler)
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/metrics", http.StatusMovedPermanently)
})
s.server = &http.Server{