2022-03-28 16:23:47 -04:00
|
|
|
//go:build debug
|
2017-05-01 09:31:57 -04:00
|
|
|
// +build debug
|
|
|
|
|
|
|
|
|
|
package debug
|
|
|
|
|
|
2022-07-16 15:41:37 -04:00
|
|
|
import "net/http"
|
2017-05-01 09:31:57 -04:00
|
|
|
|
|
|
|
|
// 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 {
|
2020-09-17 15:40:17 -04:00
|
|
|
eofRoundTripper := eofDetectRoundTripper{upstream}
|
|
|
|
|
if opts.isEnabled {
|
|
|
|
|
// only use loggingRoundTripper if the debug log is configured
|
|
|
|
|
return loggingRoundTripper{eofRoundTripper}
|
|
|
|
|
}
|
|
|
|
|
return eofRoundTripper
|
2017-05-01 09:31:57 -04:00
|
|
|
}
|