mirror of https://github.com/k3s-io/k3s
fix apiserver pprof redirect bug
parent
24117bb05c
commit
981f239781
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue