Skip to content

Instantly share code, notes, and snippets.

@patrickmcguire
Created August 2, 2017 00:02
Show Gist options
  • Save patrickmcguire/fb019f0d021911703c44d8964499408b to your computer and use it in GitHub Desktop.
Save patrickmcguire/fb019f0d021911703c44d8964499408b to your computer and use it in GitHub Desktop.
bodyReader := bytes.NewReader(payload)
err = backoff.Retry(func() error {
resp, err := http.Post(c.BaseEndpoint+"/v1/set", "application/json", bodyReader)
if err != nil {
return err
}
defer resp.Body.Close()
response := map[string]interface{}{}
dec := json.NewDecoder(resp.Body)
dec.Decode(&response)
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("HTTP Post Request Failed, Status Code %d. \nResponse: %v \nRequest payload: %v",
resp.StatusCode, response, string(payload))
}
return nil
}, b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment