Skip to content

Instantly share code, notes, and snippets.

@johnlonganecker
Created March 8, 2017 18:01
Show Gist options
  • Save johnlonganecker/9ad7bbd1b29785805ded6addaff7c54f to your computer and use it in GitHub Desktop.
Save johnlonganecker/9ad7bbd1b29785805ded6addaff7c54f to your computer and use it in GitHub Desktop.
Dump HTTP Request for debugging
import "net/http/httputil"
func (c *Client) DoRequest(r *request) (*http.Response, error) {
req, err := r.toHTTP()
if err != nil {
return nil, err
}
req.Header.Set("User-Agent", c.config.UserAgent)
if r.body != nil {
req.Header.Set("Content-type", "application/json")
}
asdf, _ := httputil.DumpRequest(req, true)
fmt.Println(string(asdf))
resp, err := c.config.HttpClient.Do(req)
return resp, err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment