MCPcopy
hub / github.com/go-chi/chi / Profiler

Function Profiler

middleware/profiler.go:23–49  ·  view source on GitHub ↗

Profiler is a convenient subrouter used for mounting net/http/pprof. ie. func MyService() http.Handler { r := chi.NewRouter() // ..middlewares r.Mount("/debug", middleware.Profiler()) // ..routes return r }

()

Source from the content-addressed store, hash-verified

21// return r
22// }
23func Profiler() http.Handler {
24 r := chi.NewRouter()
25 r.Use(NoCache)
26
27 r.Get("/", func(w http.ResponseWriter, r *http.Request) {
28 http.Redirect(w, r, r.RequestURI+"/pprof/", http.StatusMovedPermanently)
29 })
30 r.HandleFunc("/pprof", func(w http.ResponseWriter, r *http.Request) {
31 http.Redirect(w, r, r.RequestURI+"/", http.StatusMovedPermanently)
32 })
33
34 r.HandleFunc("/pprof/*", pprof.Index)
35 r.HandleFunc("/pprof/cmdline", pprof.Cmdline)
36 r.HandleFunc("/pprof/profile", pprof.Profile)
37 r.HandleFunc("/pprof/symbol", pprof.Symbol)
38 r.HandleFunc("/pprof/trace", pprof.Trace)
39 r.Handle("/vars", expvar.Handler())
40
41 r.Handle("/pprof/goroutine", pprof.Handler("goroutine"))
42 r.Handle("/pprof/threadcreate", pprof.Handler("threadcreate"))
43 r.Handle("/pprof/mutex", pprof.Handler("mutex"))
44 r.Handle("/pprof/heap", pprof.Handler("heap"))
45 r.Handle("/pprof/block", pprof.Handler("block"))
46 r.Handle("/pprof/allocs", pprof.Handler("allocs"))
47
48 return r
49}

Callers

nothing calls this directly

Calls 5

UseMethod · 0.95
GetMethod · 0.95
HandleFuncMethod · 0.95
HandleMethod · 0.95
HandlerMethod · 0.45

Tested by

no test coverage detected