Add Profiler middleware
This commit is contained in:
parent
5eabae8e40
commit
a5f83606cd
29
profiler.go
Normal file
29
profiler.go
Normal file
@ -0,0 +1,29 @@
|
||||
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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user