35 lines
654 B
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)
|
|
}
|
|
}
|
|
}
|