1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 01:57:02 +00:00

Add convenience methods to rest/client types

This commit is contained in:
James Hillyerd
2017-02-04 16:14:40 -08:00
parent cc0428ab9b
commit a1e35009e0
4 changed files with 258 additions and 28 deletions

View File

@@ -50,10 +50,9 @@ func (c *restClient) doJSON(method string, uri string, v interface{}) error {
if resp.StatusCode == http.StatusOK {
if v == nil {
return nil
} else {
// Decode response body
return json.NewDecoder(resp.Body).Decode(v)
}
// Decode response body
return json.NewDecoder(resp.Body).Decode(v)
}
return fmt.Errorf("Unexpected HTTP response status %v: %s", resp.StatusCode, resp.Status)