fix requests
parent
e0a0904c90
commit
42df57854b
19
api/cli.go
19
api/cli.go
|
@ -41,15 +41,10 @@ func (c *Cli) HttpDo(method string, strurl string, body []byte) (*http.Response,
|
|||
}
|
||||
strurl = addr + strurl
|
||||
}
|
||||
req, err := http.NewRequest(method, strurl, bytes.NewReader(body))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if c.headers != nil {
|
||||
for k, v := range c.headers {
|
||||
req.Header.Set(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
var req *http.Request
|
||||
var err error
|
||||
|
||||
if body != nil && len(body) > 0 {
|
||||
req, err = http.NewRequest(method, strurl, io.NopCloser(bytes.NewReader(body)))
|
||||
|
||||
|
@ -59,6 +54,12 @@ func (c *Cli) HttpDo(method string, strurl string, body []byte) (*http.Response,
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if c.headers != nil {
|
||||
for k, v := range c.headers {
|
||||
req.Header.Set(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
req.Header.Set("X-API-KEY", apikey)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
return c.cli.Do(req)
|
||||
|
|
Loading…
Reference in New Issue