Skip to content

Instantly share code, notes, and snippets.

@farhany
Forked from kendellfab/golang-request
Created April 5, 2018 17:45
Show Gist options
  • Save farhany/6236330c4eeb4a31bb68f582c7de6642 to your computer and use it in GitHub Desktop.
Save farhany/6236330c4eeb4a31bb68f582c7de6642 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