diff --git a/staging/src/k8s.io/apiserver/pkg/server/routes/profiling.go b/staging/src/k8s.io/apiserver/pkg/server/routes/profiling.go index f09a9669571..b57d590f523 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/routes/profiling.go +++ b/staging/src/k8s.io/apiserver/pkg/server/routes/profiling.go @@ -28,9 +28,16 @@ type Profiling struct{} // Install adds the Profiling webservice to the given mux. func (d Profiling) Install(c *mux.PathRecorderMux) { - c.UnlistedHandle("/debug/pprof", http.HandlerFunc(pprof.Index)) + c.UnlistedHandleFunc("/debug/pprof", redirectTo("/debug/pprof/")) c.UnlistedHandlePrefix("/debug/pprof/", http.HandlerFunc(pprof.Index)) c.UnlistedHandleFunc("/debug/pprof/profile", pprof.Profile) c.UnlistedHandleFunc("/debug/pprof/symbol", pprof.Symbol) c.UnlistedHandleFunc("/debug/pprof/trace", pprof.Trace) } + +// redirectTo redirects request to a certain destination. +func redirectTo(to string) func(http.ResponseWriter, *http.Request) { + return func(rw http.ResponseWriter, req *http.Request) { + http.Redirect(rw, req, to, http.StatusFound) + } +}