Created
August 2, 2017 00:02
-
-
Save patrickmcguire/fb019f0d021911703c44d8964499408b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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