30 lines
837 B
Go
30 lines
837 B
Go
package middleware
|
|
|
|
import (
|
|
"expvar"
|
|
"net/http"
|
|
"net/http/pprof"
|
|
)
|
|
|
|
// Profiler is a convenient subrouter used for mounting net/http/pprof
|
|
func Profiler() http.Handler {
|
|
mux := http.NewServeMux()
|
|
|
|
mux.HandleFunc("/pprof/", pprof.Index)
|
|
mux.HandleFunc("/pprof/cmdline", pprof.Cmdline)
|
|
mux.HandleFunc("/pprof/profile", pprof.Profile)
|
|
mux.HandleFunc("/pprof/symbol", pprof.Symbol)
|
|
mux.HandleFunc("/pprof/trace", pprof.Trace)
|
|
|
|
mux.Handle("/pprof/goroutine", pprof.Handler("goroutine"))
|
|
mux.Handle("/pprof/threadcreate", pprof.Handler("threadcreate"))
|
|
mux.Handle("/pprof/mutex", pprof.Handler("mutex"))
|
|
mux.Handle("/pprof/heap", pprof.Handler("heap"))
|
|
mux.Handle("/pprof/block", pprof.Handler("block"))
|
|
mux.Handle("/pprof/allocs", pprof.Handler("allocs"))
|
|
|
|
mux.Handle("/vars", expvar.Handler())
|
|
|
|
return Wrap(mux, NoCache)
|
|
}
|