Documentation ¶
Index ¶
- func NewLogRoundTripper(roundTripper http.RoundTripper, logger logger, dumpBody bool) http.RoundTripper
- func PrettyDumpRequest(req *http.Request, body bool) ([]byte, error)
- func PrettyDumpResponse(resp *http.Response, body bool) ([]byte, error)
- func PrettySprint(v interface{}) string
- func PrettySprintRequest(resp *http.Request) (string, error)
- func PrettySprintResponse(resp *http.Response) (string, error)
- type LogRoundTripper
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLogRoundTripper ¶
func NewLogRoundTripper(roundTripper http.RoundTripper, logger logger, dumpBody bool) http.RoundTripper
RoundTripper returns a new http.RoundTripper which logs all requests (request and response dump). Should only be used for none production envs.
func PrettyDumpRequest ¶
PrettyDumpRequest is like httputil.DumpRequest but dump is pretty formatted.
func PrettyDumpResponse ¶
PrettyDumpResponse is like httputil.DumpResponse but dump is pretty formatted.
func PrettySprint ¶
func PrettySprint(v interface{}) string
PrettySprint generates a human readable representation of the value v.
Example ¶
package main import ( "fmt" "github.com/donutloop/toolkit/debugutil" ) func main() { str := debugutil.PrettySprint([]string{}) fmt.Println(str) }
Output: []string{ }
func PrettySprintRequest ¶
PrettySprintRequest is pretty printing a http request.
Types ¶
type LogRoundTripper ¶
type LogRoundTripper struct { http.RoundTripper // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.