diff options
author | Alexander Kiryukhin <a.kiryukhin@mail.ru> | 2019-08-09 17:52:33 +0300 |
---|---|---|
committer | Alexander Kiryukhin <a.kiryukhin@mail.ru> | 2019-08-09 17:52:48 +0300 |
commit | b87e42f3294318244deae8126b3ac18d543fd3d7 (patch) | |
tree | 2b4fe1f84b07ddf80a6cb863c385293c5d2c4496 /client.go | |
parent | a8ca31679d01ddfe461cadb994131986639b4ea1 (diff) |
fix uploadsv0.2.0
Diffstat (limited to 'client.go')
-rw-r--r-- | client.go | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -10,13 +10,14 @@ import ( ) type client struct { - key string - version string - url *url.URL + key string + version string + url *url.URL + httpClient *http.Client } -func newClient(key string, version string, url *url.URL) *client { - return &client{key: key, version: version, url: url} +func newClient(key string, version string, url *url.URL, httpClient *http.Client) *client { + return &client{key: key, version: version, url: url, httpClient: httpClient} } func (cl *client) request(method, path string, query url.Values, body interface{}) (io.ReadCloser, error) { @@ -28,7 +29,6 @@ func (cl *client) request(method, path string, query url.Values, body interface{ } func (cl *client) requestReader(method, path string, query url.Values, body io.Reader) (io.ReadCloser, error) { - c := http.DefaultClient u := *cl.url u.Path = path query.Set("access_token", cl.key) @@ -38,7 +38,7 @@ func (cl *client) requestReader(method, path string, query url.Values, body io.R if err != nil { return nil, err } - resp, err := c.Do(req) + resp, err := cl.httpClient.Do(req) if err != nil { return nil, err } |