diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-08-07 18:20:47 +0200 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-08-07 18:20:58 +0200 |
commit | 6efe2b8fc9aac7fdb9f33ae1c23c4fa6ede45a08 (patch) | |
tree | 520eeb84d821eaa08bc6d1a78eda677b5d7cf848 /golib | |
parent | d1debb34de2758c0931ac794855b63066c38cd85 (diff) |
Make ResponseToBArray of httpclient public.
Diffstat (limited to 'golib')
-rw-r--r-- | golib/httpclient.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/golib/httpclient.go b/golib/httpclient.go index 72132bf..597760c 100644 --- a/golib/httpclient.go +++ b/golib/httpclient.go @@ -154,7 +154,7 @@ func (c *HTTPClient) HTTPGetWithRes(url string, data *[]byte) (*http.Response, e return res, errors.New(res.Status) } - *data = c.responseToBArray(res) + *data = c.ResponseToBArray(res) return res, nil } @@ -181,7 +181,7 @@ func (c *HTTPClient) HTTPPostWithRes(url string, body string) (*http.Response, e return res, nil } -func (c *HTTPClient) responseToBArray(response *http.Response) []byte { +func (c *HTTPClient) ResponseToBArray(response *http.Response) []byte { defer response.Body.Close() bytes, err := ioutil.ReadAll(response.Body) if err != nil { @@ -242,11 +242,11 @@ csrffound: } else if response.StatusCode != 200 { data := make(map[string]interface{}) // Try to decode error field of APIError struct - json.Unmarshal(c.responseToBArray(response), &data) + json.Unmarshal(c.ResponseToBArray(response), &data) if err, found := data["error"]; found { return nil, fmt.Errorf(err.(string)) } else { - body := strings.TrimSpace(string(c.responseToBArray(response))) + body := strings.TrimSpace(string(c.ResponseToBArray(response))) if body != "" { return nil, fmt.Errorf(body) } |