This repository has been archived on 2021-08-10. You can view files and clone it, but cannot push or open issues or pull requests.
gtools/router/debug.go

35 lines
654 B
Go

package router
import (
"net/http"
"net/http/pprof"
"github.com/gorilla/mux"
)
// HandlePprof pprof index
func (re *Router) HandlePprof() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
pprof.Index(w, r)
}
}
// HandlePprofProfile pprof profile
func (re *Router) HandlePprofProfile() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
switch vars["pprof"] {
case "cmdline":
pprof.Cmdline(w, r)
case "profile":
pprof.Profile(w, r)
case "symbol":
pprof.Symbol(w, r)
case "trace":
pprof.Trace(w, r)
default:
re.HandlePprof().ServeHTTP(w, r)
}
}
}