Skip to content

Commit

Permalink
server/server.go: fix newHTTPServer() to accept a nil http.ServeMux
Browse files Browse the repository at this point in the history
When creating the profiling server, the handler is set to nil.
This fix prevents the function newHTTPServer() to call
apihttp.LogHandler(nil), which is unsupported and produces a crash.

@jllucas, this removes a blocker for testing the integration with
prometheus \o/
  • Loading branch information
panchoh committed Jan 11, 2019
1 parent bb28636 commit fade03e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,15 @@ func newTLSServer(addr string, mux *http.ServeMux) *http.Server {
}

func newHTTPServer(addr string, mux *http.ServeMux) *http.Server {
var handler http.Handler
if mux != nil {
handler = apihttp.LogHandler(mux)
} else {
handler = nil
}

return &http.Server{
Addr: addr,
Handler: apihttp.LogHandler(mux),
Handler: handler,
}
}

0 comments on commit fade03e

Please sign in to comment.