aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
authorAlexander Kiryukhin <a.kiryukhin@mail.ru>2019-08-09 17:52:33 +0300
committerAlexander Kiryukhin <a.kiryukhin@mail.ru>2019-08-09 17:52:48 +0300
commitb87e42f3294318244deae8126b3ac18d543fd3d7 (patch)
tree2b4fe1f84b07ddf80a6cb863c385293c5d2c4496 /client.go
parenta8ca31679d01ddfe461cadb994131986639b4ea1 (diff)
fix uploadsv0.2.0
Diffstat (limited to 'client.go')
-rw-r--r--client.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/client.go b/client.go
index 3102e99..7c5c079 100644
--- a/client.go
+++ b/client.go
@@ -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
}