1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-api-healthcheck synced 2026-06-18 05:00:03 +02:00

eosapi/functions.go: Actually check errors from send().

This commit is contained in:
Henrik Hautakoski 2020-02-07 07:23:22 +01:00
parent 4a73480603
commit 94cdc7117c

View file

@ -37,11 +37,13 @@ func GetInfo(host string, port int) (Info, error) {
var info Info;
r, err := send("GET", host, port, "/v1/chain/get_info");
resp := r.Response()
body, _ := ioutil.ReadAll(resp.Body);
if err == nil {
resp := r.Response()
body, _ := ioutil.ReadAll(resp.Body);
// Parse json
err = json.Unmarshal(body, &info);
// Parse json
err = json.Unmarshal(body, &info);
}
return info, err;
}
@ -50,10 +52,12 @@ func GetHealth(host string, port int) (Health, error) {
var health Health;
r, err := send("GET", host, port, "/v2/health");
resp := r.Response()
body, _ := ioutil.ReadAll(resp.Body);
if err == nil {
resp := r.Response()
body, _ := ioutil.ReadAll(resp.Body);
// Parse json
err = json.Unmarshal(body, &health);
// Parse json
err = json.Unmarshal(body, &health);
}
return health, err;
}