From 6efe2b8fc9aac7fdb9f33ae1c23c4fa6ede45a08 Mon Sep 17 00:00:00 2001 From: Sebastien Douheret Date: Mon, 7 Aug 2017 18:20:47 +0200 Subject: Make ResponseToBArray of httpclient public. --- golib/httpclient.go | 8 ++++---- 1 file 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) } -- cgit 1.2.3-korg