Skip to content

Commit 18ee386

Browse files
committed
增加扩展debug接口
1 parent f416544 commit 18ee386

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

debug/pprof.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ func RunDebug(name string) {
2828
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
2929
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
3030
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
31-
31+
for path, handler := range appendHandler {
32+
mux.HandleFunc(path, handler)
33+
}
3234
lAddr := listen.Addr().(*net.TCPAddr)
3335

3436
log.Infof("start pprof:\thttp%s:%d", lAddr.IP.String(), lAddr.Port)
@@ -44,3 +46,11 @@ func RunDebug(name string) {
4446
}()
4547

4648
}
49+
50+
var (
51+
appendHandler = map[string]func(w http.ResponseWriter, r *http.Request){}
52+
)
53+
54+
func Register(s string, handler func(w http.ResponseWriter, r *http.Request)) {
55+
appendHandler[s] = handler
56+
}

0 commit comments

Comments
 (0)