From ecf33aed8afbde53f5e1fbdd7a9389afe66588ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Sima=CC=83o?= Date: Sun, 31 Oct 2021 06:35:05 -0300 Subject: [PATCH] Add SetCli, Remove defer body.close from Do --- lib.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib.go b/lib.go index e5649d8..87303c9 100644 --- a/lib.go +++ b/lib.go @@ -16,6 +16,9 @@ type Cli struct { basePath string } +func (c *Cli) SetCli(h *http.Client) { + c.cli = h +} func (c *Cli) BasePath() string { return c.basePath } @@ -60,7 +63,6 @@ func (c *Cli) Do(method string, strurl string, body []byte) (*http.Response, err if err != nil { return nil, err } - defer res.Body.Close() if res.StatusCode >= 400 { return nil, errors.New(fmt.Sprintf("Http return code - %d: %s", res.StatusCode, res.Status)) }