Add SetCli, Remove defer body.close from Do
parent
45fd265264
commit
ecf33aed8a
4
lib.go
4
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))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue