return error when not 200 for GET method

This commit is contained in:
Yasuhiro Matsumoto 2017-04-14 17:37:50 +09:00
parent d1e98eb548
commit dd7163e01e

View File

@ -47,6 +47,11 @@ func (c *Client) doAPI(method string, uri string, params url.Values, res interfa
if res == nil {
return nil
}
if method == "GET" && resp.StatusCode != 200 {
return fmt.Errorf("bad request: %v", resp.Status)
}
return json.NewDecoder(resp.Body).Decode(&res)
}