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:
parent
4a73480603
commit
94cdc7117c
1 changed files with 12 additions and 8 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue