// Package httpdebug provides HTTP handler for debug endpoints.
package httpdebug import ( ) // New returns a new HTTP handler for debug endpoints. func () http.Handler { := http.NewServeMux() .HandleFunc("/debug/pprof/", pprof.Index) .HandleFunc("/debug/pprof/cmdline", pprof.Cmdline) .HandleFunc("/debug/pprof/profile", pprof.Profile) .HandleFunc("/debug/pprof/symbol", pprof.Symbol) .Handle("/debug/pprof/goroutine", pprof.Handler("goroutine")) .Handle("/debug/pprof/heap", pprof.Handler("heap")) .Handle("/debug/pprof/threadcreate", pprof.Handler("threadcreate")) .Handle("/debug/pprof/block", pprof.Handler("block")) .Handle("/debug/vars", expvar.Handler()) .HandleFunc("/debug/events", trace.Events) .HandleFunc("/debug/requests", trace.Traces) .HandleFunc("/debug/buildinfo", func( http.ResponseWriter, *http.Request) { , := debug.ReadBuildInfo() if ! { .WriteHeader(http.StatusNotImplemented) return } := .String() := .Header() .Set("Content-Type", "text/plain; charset=utf-8") .Set("Content-Length", strconv.Itoa(len())) _, _ = io.WriteString(, ) }) .HandleFunc("/debug/", func( http.ResponseWriter, *http.Request) { := .Header() .Set("Content-Type", "text/html; charset=utf-8") .Set("Content-Length", strconv.Itoa(len(debugPage))) _, _ = io.WriteString(, debugPage) }) return } const debugPage = `<!doctype html> <title>Debug</title> <meta name=viewport content="width=device-width"> <ul> <li><a href=/debug/pprof>pprof</a></li> <li><a href=/debug/events>events</a></li> <li><a href=/debug/requests>traces</a></li> </ul> `