-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
examples_test.go
60 lines (47 loc) · 1.73 KB
/
examples_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package debughttp_test
import (
"net/http"
"github.com/rclone/debughttp"
)
var (
existingTransport *http.Transport
transport *debughttp.Transport
client *http.Client
)
func myLogf(format string, v ...interface{}) {}
func ExampleNewClient() {
// Make a client with the defaults which dump headers to log.Printf
client = debughttp.NewClient(nil)
// Make a client which dumps headers and bodies to log.Printf
client = debughttp.NewClient(&debughttp.DumpBodyOptions)
// Make a client with full options
// This dumps headers, request bodies and doesn't redact the auth
client = debughttp.NewClient(&debughttp.Options{
Flags: debughttp.DumpRequests | debughttp.DumpAuth,
Logf: myLogf,
})
}
func ExampleNewDefault() {
// Make a transport with the defaults which dump headers to log.Printf
transport = debughttp.NewDefault(nil)
// Make a transport which dumps headers and bodies to log.Printf
transport = debughttp.NewDefault(&debughttp.DumpBodyOptions)
// Make a transport with full options
// This dumps headers, request bodies and doesn't redact the auth
transport = debughttp.NewDefault(&debughttp.Options{
Flags: debughttp.DumpRequests | debughttp.DumpAuth,
Logf: myLogf,
})
}
func ExampleNew() {
// Make a transport with the defaults which dump headers to log.Printf
transport = debughttp.New(nil, existingTransport)
// Make a transport which dumps headers and bodies to log.Printf
transport = debughttp.New(&debughttp.DumpBodyOptions, existingTransport)
// Make a transport with full options
// This dumps headers, request bodies and doesn't redact the auth
transport = debughttp.New(&debughttp.Options{
Flags: debughttp.DumpRequests | debughttp.DumpAuth,
Logf: myLogf,
}, existingTransport)
}