middleware/profiler.go
func Profiler() http.Handler {
	r := chi.NewRouter()
	r.Use(NoCache)

	r.Get("/", func(w http.ResponseWriter, r *http.Request) {
		http.Redirect(w, r, r.RequestURI+"/pprof/", 301)
	})
	r.HandleFunc("/pprof", func(w http.ResponseWriter, r *http.Request) {
		http.Redirect(w, r, r.RequestURI+"/", 301)
	})

	r.HandleFunc("/pprof/*", pprof.Index)
	r.HandleFunc("/pprof/cmdline", pprof.Cmdline)
	r.HandleFunc("/pprof/profile", pprof.Profile)
	r.HandleFunc("/pprof/symbol", pprof.Symbol)
	r.HandleFunc("/pprof/trace", pprof.Trace)
	r.HandleFunc("/vars", expVars)

	return r
}
func Profiler() http.Handler {
	r := chi.NewRouter()
	r.Use(NoCache)

	r.Get("/", func(w http.ResponseWriter, r *http.Request) {
		http.Redirect(w, r, r.RequestURI+"/pprof/", 301)
	})
	r.HandleFunc("/pprof", func(w http.ResponseWriter, r *http.Request) {
		http.Redirect(w, r, r.RequestURI+"/", 301)
	})

	r.HandleFunc("/pprof/*", pprof.Index)
	r.HandleFunc("/pprof/cmdline", pprof.Cmdline)
	r.HandleFunc("/pprof/profile", pprof.Profile)
	r.HandleFunc("/pprof/symbol", pprof.Symbol)
	r.HandleFunc("/pprof/trace", pprof.Trace)
	r.HandleFunc("/vars", expVars)

	return r
}
func Profiler ( ) http . Handler { r := chi . NewRouter ( ) r . Use ( NoCache ) r . Get ( " " , func ( w http . ResponseWriter , r * http . Request ) { http . Redirect ( w , r , r . RequestURI + " " , 301 ) } ) r . HandleFunc ( " " , func ( w http . ResponseWriter , r * http . Request ) { http . Redirect ( w , r , r . RequestURI + " " , 301 ) } ) r . HandleFunc ( " " , pprof . Index ) r . HandleFunc ( " " , pprof . Cmdline ) r . HandleFunc ( " " , pprof . Profile ) r . HandleFunc ( " " , pprof . Symbol ) r . HandleFunc ( " " , pprof . Trace ) r . HandleFunc ( " " , expVars ) return r }
// 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
//  }
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 }