debug: support roundtripper logging also for release builds

Different from debug builds do not use the eofDetectRoundTripper if
logging is disabled.
This commit is contained in:
Michael Eischer
2022-07-16 21:41:37 +02:00
parent 38becfc436
commit 1ed775e3a8
4 changed files with 121 additions and 116 deletions

View File

@@ -8,5 +8,9 @@ import "net/http"
// RoundTripper returns a new http.RoundTripper which logs all requests (if
// debug is enabled). When debug is not enabled, upstream is returned.
func RoundTripper(upstream http.RoundTripper) http.RoundTripper {
if opts.isEnabled {
// only use loggingRoundTripper if the debug log is configured
return loggingRoundTripper{eofDetectRoundTripper{upstream}}
}
return upstream
}