(req *http.Request)
| 441 | } |
| 442 | |
| 443 | func printRequest(req *http.Request) error { |
| 444 | reqContentType := req.Header.Get("Content-Type") |
| 445 | printBody := shouldPrintBody(reqContentType) |
| 446 | reqDump, err := httputil.DumpRequest(req, printBody) |
| 447 | if err != nil { |
| 448 | return errors.Wrap(err, "dump request failed") |
| 449 | } |
| 450 | fmt.Println("-------------------- request --------------------") |
| 451 | reqContent := string(reqDump) |
| 452 | if reqContentType != "" && !printBody { |
| 453 | reqContent += fmt.Sprintf("(request body omitted for Content-Type: %v)", reqContentType) |
| 454 | } |
| 455 | fmt.Println(reqContent) |
| 456 | return nil |
| 457 | } |
| 458 | |
| 459 | func printf(format string, a ...interface{}) (n int, err error) { |
| 460 | return fmt.Fprintf(color.Output, format, a...) |
no test coverage detected