Documentation ¶
Overview ¶
Package loghttp provides automatic logging functionalities to http.Client.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ContextKeyRequestStart = &contextKey{"RequestStart"}
View Source
var DefaultLogRequest = func(req *http.Request) { requestDump, err := httputil.DumpRequest(req, true) if err != nil { fmt.Println(err) } fmt.Println(string(requestDump)) fmt.Println() }
Used if transport.LogRequest is not set.
View Source
var DefaultLogResponse = func(resp *http.Response) { ctx := resp.Request.Context() if start, ok := ctx.Value(ContextKeyRequestStart).(time.Time); ok { log.Printf("<-- %d %s (%s)", resp.StatusCode, resp.Request.URL, roundtime.Duration(time.Now().Sub(start), 2)) } else { log.Printf("<-- %d %s", resp.StatusCode, resp.Request.URL) } }
Used if transport.LogResponse is not set.
View Source
var DefaultTransport = &Transport{ Transport: http.DefaultTransport, }
THe default logging transport that wraps http.DefaultTransport.
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.