File: round_tripper_debug.go

package info (click to toggle)
restic 0.18.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 30,824 kB
  • sloc: sh: 3,704; makefile: 50; python: 34
file content (17 lines) | stat: -rw-r--r-- 494 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//go:build debug
// +build debug

package debug

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 {
	eofRoundTripper := eofDetectRoundTripper{upstream}
	if opts.isEnabled {
		// only use loggingRoundTripper if the debug log is configured
		return loggingRoundTripper{eofRoundTripper}
	}
	return eofRoundTripper
}