web: fix profile paths
@@ -246,19 +246,23 @@ func serveDebug(w http.ResponseWriter, req *http.Request) {
ctx := req.Context()
subpath := route.Param(ctx, "subpath")
- // Based off paths from init() in golang.org/src/net/http/pprof/pprof.go
- if subpath == "/pprof/" {
- pprof.Index(w, req)
- } else if subpath == "/pprof/cmdline" {
+ if !strings.HasPrefix(subpath, "/pprof/") {
+ http.NotFound(w, req)
+ return
+ }
+ subpath = strings.TrimPrefix(subpath, "/pprof/")
+
+ switch subpath {
+ case "cmdline":
pprof.Cmdline(w, req)
- } else if subpath == "/pprof/profile" {
+ case "profile":
pprof.Profile(w, req)
- } else if subpath == "/pprof/symbol" {
+ case "symbol":
pprof.Symbol(w, req)
- } else if subpath == "/pprof/trace" {
+ case "trace":
pprof.Trace(w, req)
- } else {
- http.NotFound(w, req)
+ default:
+ pprof.Index(w, req)
}
}
