gfwproxyshadowsocksdocker-imagegogolanggvisornatnetworksocks4socks5tcpip-stacktortun-devicetun2sockstunneludpwireguard
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
605 B
30 lines
605 B
//go:build debug
|
|
|
|
package restapi
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/pprof"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
func init() {
|
|
registerMountPoint("/debug/pprof/", pprofRouter())
|
|
}
|
|
|
|
func pprofRouter() http.Handler {
|
|
r := chi.NewRouter()
|
|
r.HandleFunc("/", pprof.Index)
|
|
r.HandleFunc("/cmdline", pprof.Cmdline)
|
|
r.HandleFunc("/profile", pprof.Profile)
|
|
r.HandleFunc("/symbol", pprof.Symbol)
|
|
r.HandleFunc("/trace", pprof.Trace)
|
|
r.HandleFunc("/{name}", pprofHandler)
|
|
return r
|
|
}
|
|
|
|
func pprofHandler(w http.ResponseWriter, r *http.Request) {
|
|
name := chi.URLParam(r, "name")
|
|
pprof.Handler(name).ServeHTTP(w, r)
|
|
}
|
|
|