Skip to content

Instantly share code, notes, and snippets.

@thurt
Forked from kendellfab/golang-request
Created June 16, 2017 00:42
Show Gist options
  • Save thurt/9d3998045e3160dec4e73c2855e0fcf2 to your computer and use it in GitHub Desktop.
Save thurt/9d3998045e3160dec4e73c2855e0fcf2 to your computer and use it in GitHub Desktop.
Golang Example for adding custom headers to a request.
client := &http.Client{]
req, err := http.NewRequest("POST", "http://example.com", bytes.NewReader(postData))
req.Header.Add("User-Agent", "myClient")
resp, err := client.Do(req)
defer resp.Body.Close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment