mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 14:20:55 +03:00
httpd: move the check connection middleware before the logger middleware
Fixes #543
This commit is contained in:
@@ -190,7 +190,10 @@ func Get(url string) (*http.Response, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
addHeaders(req, url)
|
addHeaders(req, url)
|
||||||
return GetHTTPClient().Do(req)
|
client := GetHTTPClient()
|
||||||
|
defer client.CloseIdleConnections()
|
||||||
|
|
||||||
|
return client.Do(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Post issues a POST to the specified URL
|
// Post issues a POST to the specified URL
|
||||||
@@ -201,7 +204,10 @@ func Post(url string, contentType string, body io.Reader) (*http.Response, error
|
|||||||
}
|
}
|
||||||
req.Header.Set("Content-Type", contentType)
|
req.Header.Set("Content-Type", contentType)
|
||||||
addHeaders(req, url)
|
addHeaders(req, url)
|
||||||
return GetHTTPClient().Do(req)
|
client := GetHTTPClient()
|
||||||
|
defer client.CloseIdleConnections()
|
||||||
|
|
||||||
|
return client.Do(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RetryableGet issues a GET to the specified URL using the retryable client
|
// RetryableGet issues a GET to the specified URL using the retryable client
|
||||||
@@ -211,7 +217,10 @@ func RetryableGet(url string) (*http.Response, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
addHeadersToRetryableReq(req, url)
|
addHeadersToRetryableReq(req, url)
|
||||||
return GetRetraybleHTTPClient().Do(req)
|
client := GetRetraybleHTTPClient()
|
||||||
|
defer client.HTTPClient.CloseIdleConnections()
|
||||||
|
|
||||||
|
return client.Do(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RetryablePost issues a POST to the specified URL using the retryable client
|
// RetryablePost issues a POST to the specified URL using the retryable client
|
||||||
@@ -222,7 +231,10 @@ func RetryablePost(url string, contentType string, body io.Reader) (*http.Respon
|
|||||||
}
|
}
|
||||||
req.Header.Set("Content-Type", contentType)
|
req.Header.Set("Content-Type", contentType)
|
||||||
addHeadersToRetryableReq(req, url)
|
addHeadersToRetryableReq(req, url)
|
||||||
return GetRetraybleHTTPClient().Do(req)
|
client := GetRetraybleHTTPClient()
|
||||||
|
defer client.HTTPClient.CloseIdleConnections()
|
||||||
|
|
||||||
|
return client.Do(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func addHeaders(req *http.Request, url string) {
|
func addHeaders(req *http.Request, url string) {
|
||||||
|
|||||||
@@ -530,9 +530,9 @@ func (s *httpdServer) initializeRouter() {
|
|||||||
s.router = chi.NewRouter()
|
s.router = chi.NewRouter()
|
||||||
|
|
||||||
s.router.Use(middleware.RequestID)
|
s.router.Use(middleware.RequestID)
|
||||||
|
s.router.Use(s.checkConnection)
|
||||||
s.router.Use(logger.NewStructuredLogger(logger.GetLogger()))
|
s.router.Use(logger.NewStructuredLogger(logger.GetLogger()))
|
||||||
s.router.Use(recoverer)
|
s.router.Use(recoverer)
|
||||||
s.router.Use(s.checkConnection)
|
|
||||||
s.router.Use(middleware.GetHead)
|
s.router.Use(middleware.GetHead)
|
||||||
s.router.Use(middleware.StripSlashes)
|
s.router.Use(middleware.StripSlashes)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user