2023-09-13 17:00:24 +00:00
|
|
|
/*
|
|
|
|
Copyright © 2023 Seednode <seednode@seedno.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2023-09-28 11:15:10 +00:00
|
|
|
"fmt"
|
|
|
|
"net/http"
|
2023-09-13 17:00:24 +00:00
|
|
|
"net/http/pprof"
|
2023-09-28 11:15:10 +00:00
|
|
|
"time"
|
2023-09-13 17:00:24 +00:00
|
|
|
|
|
|
|
"github.com/julienschmidt/httprouter"
|
|
|
|
)
|
|
|
|
|
2023-09-28 11:15:10 +00:00
|
|
|
func registerProfileHandler(mux *httprouter.Router, verb, path string, handler http.HandlerFunc) {
|
|
|
|
mux.HandlerFunc(verb, path, handler)
|
|
|
|
|
|
|
|
if Handlers {
|
|
|
|
fmt.Printf("%s | SERVE: Registered handler for %s\n",
|
|
|
|
time.Now().Format(logDate),
|
|
|
|
path,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-13 17:00:24 +00:00
|
|
|
func registerProfileHandlers(mux *httprouter.Router) {
|
2023-12-17 12:35:03 +00:00
|
|
|
registerProfileHandler(mux, "GET", Prefix+AdminPrefix+"/debug/pprof/", pprof.Index)
|
|
|
|
registerProfileHandler(mux, "GET", Prefix+AdminPrefix+"/debug/pprof/cmdline", pprof.Cmdline)
|
|
|
|
registerProfileHandler(mux, "GET", Prefix+AdminPrefix+"/debug/pprof/profile", pprof.Profile)
|
|
|
|
registerProfileHandler(mux, "GET", Prefix+AdminPrefix+"/debug/pprof/symbol", pprof.Symbol)
|
|
|
|
registerProfileHandler(mux, "GET", Prefix+AdminPrefix+"/debug/pprof/trace", pprof.Trace)
|
2023-09-13 17:00:24 +00:00
|
|
|
}
|