Skip to content

Commit

Permalink
added(debug): safely display headers of http.Request
Browse files Browse the repository at this point in the history
[changelog]
  • Loading branch information
aseure committed Jul 11, 2019
1 parent d084265 commit f70903b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion algolia/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,15 @@ func printRequest(req *http.Request) {
var body string
req.Body, body = copyReadCloser(req.Body)
body = prettyPrintJSON(body, "\t")
fmt.Printf("> ALGOLIA DEBUG request:\n\tmethod=%q\n\turl=%q\n\tbody=\n\t%s\n", req.Method, req.URL, body)
fmt.Printf("> ALGOLIA DEBUG request:\n\tmethod=%q\n\turl=%q\n", req.Method, req.URL)
for k, v := range req.Header {
str := strings.Join(v, ",")
if strings.Contains(strings.ToLower(k), "algolia") {
str = strings.Repeat("*", len(str))
}
fmt.Printf("\theader=%s:%q\n", k, str)
}
fmt.Printf("\tbody=\n\t%s\n", body)
}

func printResponse(res *http.Response) {
Expand Down

0 comments on commit f70903b

Please sign in to comment.