Skip to content

Commit

Permalink
Merge pull request #35 from dsrvlabs/gnong-2
Browse files Browse the repository at this point in the history
Add code to close the http client
  • Loading branch information
heejin-github authored Oct 30, 2023
2 parents 2b99bf5 + 4b82916 commit 0cbbaa7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rpc/cosmos/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ func GetStatus(rpcAddr string) (*Status, error) {
return nil, fmt.Errorf("request failed %s", string(rawBody))
}

defer resp.Body.Close()

status, err := parseRawStatus(rawBody)
if err != nil {
return nil, err
Expand Down
3 changes: 3 additions & 0 deletions rpc/cosmos/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ func GetHealth(rpcAddr string) (int, error) {
log.Error().Str("Response", "Error").Msg(fmt.Sprintf("%v", err))
return -1, err
}

defer resp.Body.Close()

return resp.StatusCode, nil
}
2 changes: 2 additions & 0 deletions rpc/cosmos/net_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ func GetNpeers(rpcAddr string) (string, error) {
return strconv.Itoa(resp.StatusCode), fmt.Errorf("request failed %s", string(rawBody))
}

defer resp.Body.Close()

info := netInfo{}
err = json.Unmarshal(rawBody, &info)

Expand Down
2 changes: 2 additions & 0 deletions rpc/cosmos/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func GetBondStatus(rpcAddr string, valoperAddr string) (bool, error) {
return false, fmt.Errorf("request failed %d %s", resp.StatusCode, string(rawBody))
}

defer resp.Body.Close()

status := validatorStatus{}
err = json.Unmarshal(rawBody, &status)

Expand Down

0 comments on commit 0cbbaa7

Please sign in to comment.