IrekFasikhov / go-rgwadmin

Ceph RADOS Gateway admin(golang)
https://irekfasikhov.com
GNU General Public License v3.0
10 stars 2 forks source link

Unhandled httpstatus of reponse #4

Open lvnux opened 4 years ago

lvnux commented 4 years ago
resp, err := api.client.Do(re)

if err != nil {
    return nil, err
}
body, err = ioutil.ReadAll(resp.Body)

return body, err

handle httpstatus of response maybe better:

resp, err := api.client.Do(re)

if err != nil {
    return nil, err
}

body, err = ioutil.ReadAll(resp.Body)

if resp.StatusCode != http.StatusOK {
    return nil, fmt.Errorf("rgw response httpstatus with code %d, %s", resp.StatusCode, string(body))
}

return body, err
IrekFasikhov commented 4 years ago

Good! Please create PR. Thanks