diff --git a/json.go b/json.go index 690c62b..8997bab 100644 --- a/json.go +++ b/json.go @@ -46,6 +46,10 @@ func GetJSON(url string, v interface{}, params url.Values, headers http.Header) defer resp.Body.Close() status = resp.StatusCode + if status != http.StatusOK { + return status, err + } + if err = DecodeJSON(resp.Body, v); err == io.EOF { err = nil } @@ -87,6 +91,10 @@ func PostJSON(url string, v, r interface{}, params url.Values, headers http.Head status = resp.StatusCode defer resp.Body.Close() + if status != http.StatusOK && status != http.StatusCreated { + return status, err + } + if err = DecodeJSON(resp.Body, v); err == io.EOF { err = nil }