Skip to content

Commit 3a82175

Browse files
committed
Add 'Profiler' option to ServerConfig
This enables the http/pprof endpoints.
1 parent 8fa83a3 commit 3a82175

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

server.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type ServerConfig struct {
2424
Port int
2525
CookieSecret string
2626
RecoverPanic bool
27+
Profiler bool
2728
}
2829

2930
// Server represents a web.go server.
@@ -116,10 +117,12 @@ func (s *Server) Run(addr string) {
116117
s.initServer()
117118

118119
mux := http.NewServeMux()
119-
mux.Handle("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline))
120-
mux.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))
121-
mux.Handle("/debug/pprof/heap", pprof.Handler("heap"))
122-
mux.Handle("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol))
120+
if s.Config.Profiler {
121+
mux.Handle("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline))
122+
mux.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))
123+
mux.Handle("/debug/pprof/heap", pprof.Handler("heap"))
124+
mux.Handle("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol))
125+
}
123126
mux.Handle("/", s)
124127

125128
s.Logger.Printf("web.go serving %s\n", addr)

0 commit comments

Comments
 (0)