b2_go17.go
raw| 1 | // +build go1.7 |
| 2 | |
| 3 | package b2 |
| 4 | |
| 5 | import ( |
| 6 | "net/http" |
| 7 | "net/http/httptrace" |
| 8 | ) |
| 9 | |
| 10 | func addTracing(req *http.Request) *http.Request { |
| 11 | trace := &httptrace.ClientTrace{ |
| 12 | ConnectStart: func(network, addr string) { |
| 13 | debugf("new connection to %s (for %s)", addr, req.URL.Path) |
| 14 | }, |
| 15 | } |
| 16 | return req.WithContext(httptrace.WithClientTrace(req.Context(), trace)) |
| 17 | } |
| 18 | |
| 19 | func init() { |
| 20 | requestExtFunc = addTracing |
| 21 | } |