mirror of
https://github.com/m1k1o/neko-rooms.git
synced 2026-11-02 22:51:34 -06:00
34 lines
592 B
Go
34 lines
592 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/pprof"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
const pprofPath = "/debug/pprof/"
|
|
|
|
func withPProf(router *chi.Mux) {
|
|
router.Route(pprofPath, func(r chi.Router) {
|
|
r.Get("/", pprof.Index)
|
|
|
|
r.Get("/{action}", func(w http.ResponseWriter, r *http.Request) {
|
|
action := chi.URLParam(r, "action")
|
|
|
|
switch action {
|
|
case "cmdline":
|
|
pprof.Cmdline(w, r)
|
|
case "profile":
|
|
pprof.Profile(w, r)
|
|
case "symbol":
|
|
pprof.Symbol(w, r)
|
|
case "trace":
|
|
pprof.Trace(w, r)
|
|
default:
|
|
pprof.Handler(action).ServeHTTP(w, r)
|
|
}
|
|
})
|
|
})
|
|
}
|