Skip to content

Instantly share code, notes, and snippets.

@patrickmcguire
Last active August 1, 2017 23:57
Show Gist options
  • Save patrickmcguire/c02009e0d4cd0cd30e0d46dedbf34509 to your computer and use it in GitHub Desktop.
Save patrickmcguire/c02009e0d4cd0cd30e0d46dedbf34509 to your computer and use it in GitHub Desktop.
err = backoff.Retry(func() error {
bodyReader := bytes.NewReader(payload)
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