Skip to content
Snippets Groups Projects
Commit 29b9513a authored by ale's avatar ale
Browse files

Correctly handle the case when config is nil

parent d4396660
No related branches found
No related tags found
No related merge requests found
...@@ -60,20 +60,19 @@ func (config *ServerConfig) buildHTTPServer(h http.Handler) (*http.Server, error ...@@ -60,20 +60,19 @@ func (config *ServerConfig) buildHTTPServer(h http.Handler) (*http.Server, error
if config.MaxInflightRequests > 0 { if config.MaxInflightRequests > 0 {
h = newLoadSheddingWrapper(config.MaxInflightRequests, h) h = newLoadSheddingWrapper(config.MaxInflightRequests, h)
} }
}
// Wrap the handler with a TimeoutHandler if 'request_timeout' // Wrap the handler with a TimeoutHandler if 'request_timeout'
// is set. // is set.
h = addDefaultHandlers(h) if config.RequestTimeoutSecs > 0 {
if config.RequestTimeoutSecs > 0 { h = http.TimeoutHandler(h, time.Duration(config.RequestTimeoutSecs)*time.Second, "")
h = http.TimeoutHandler(h, time.Duration(config.RequestTimeoutSecs)*time.Second, "") }
} }
// These are not meant to be external-facing servers, so we // These are not meant to be external-facing servers, so we
// can be generous with the timeouts to keep the number of // can be generous with the timeouts to keep the number of
// reconnections low. // reconnections low.
return &http.Server{ return &http.Server{
Handler: h, Handler: addDefaultHandlers(h),
ReadTimeout: 30 * time.Second, ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second, WriteTimeout: 30 * time.Second,
IdleTimeout: 600 * time.Second, IdleTimeout: 600 * time.Second,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment