summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/slack-go/slack/misc.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-04-25 23:50:10 +0200
committerGitHub <noreply@github.com>2022-04-25 23:50:10 +0200
commit67adad3e08fe17d5f7e87468ea47aa76e1662255 (patch)
tree91314fac90d39254e66ae794decfcd21c10a7b20 /vendor/github.com/slack-go/slack/misc.go
parent2fca3c756373577eab4e0120ccce62eecc1f5ad8 (diff)
downloadmatterbridge-msglm-67adad3e08fe17d5f7e87468ea47aa76e1662255.tar.gz
matterbridge-msglm-67adad3e08fe17d5f7e87468ea47aa76e1662255.tar.bz2
matterbridge-msglm-67adad3e08fe17d5f7e87468ea47aa76e1662255.zip
Update dependencies (#1813)
Diffstat (limited to 'vendor/github.com/slack-go/slack/misc.go')
-rw-r--r--vendor/github.com/slack-go/slack/misc.go26
1 files changed, 11 insertions, 15 deletions
diff --git a/vendor/github.com/slack-go/slack/misc.go b/vendor/github.com/slack-go/slack/misc.go
index 5272e7c4..804724d7 100644
--- a/vendor/github.com/slack-go/slack/misc.go
+++ b/vendor/github.com/slack-go/slack/misc.go
@@ -66,29 +66,27 @@ func (e *RateLimitedError) Retryable() bool {
}
func fileUploadReq(ctx context.Context, path string, values url.Values, r io.Reader) (*http.Request, error) {
- req, err := http.NewRequest("POST", path, r)
+ req, err := http.NewRequestWithContext(ctx, http.MethodPost, path, r)
if err != nil {
return nil, err
}
- req = req.WithContext(ctx)
- req.URL.RawQuery = (values).Encode()
+ req.URL.RawQuery = values.Encode()
return req, nil
}
-func downloadFile(client httpClient, token string, downloadURL string, writer io.Writer, d Debug) error {
+func downloadFile(ctx context.Context, client httpClient, token string, downloadURL string, writer io.Writer, d Debug) error {
if downloadURL == "" {
return fmt.Errorf("received empty download URL")
}
- req, err := http.NewRequest("GET", downloadURL, &bytes.Buffer{})
+ req, err := http.NewRequestWithContext(ctx, http.MethodGet, downloadURL, &bytes.Buffer{})
if err != nil {
return err
}
var bearer = "Bearer " + token
req.Header.Add("Authorization", bearer)
- req.WithContext(context.Background())
resp, err := client.Do(req)
if err != nil {
@@ -107,8 +105,8 @@ func downloadFile(client httpClient, token string, downloadURL string, writer io
return err
}
-func formReq(endpoint string, values url.Values) (req *http.Request, err error) {
- if req, err = http.NewRequest("POST", endpoint, strings.NewReader(values.Encode())); err != nil {
+func formReq(ctx context.Context, endpoint string, values url.Values) (req *http.Request, err error) {
+ if req, err = http.NewRequestWithContext(ctx, http.MethodPost, endpoint, strings.NewReader(values.Encode())); err != nil {
return nil, err
}
@@ -116,13 +114,13 @@ func formReq(endpoint string, values url.Values) (req *http.Request, err error)
return req, nil
}
-func jsonReq(endpoint string, body interface{}) (req *http.Request, err error) {
+func jsonReq(ctx context.Context, endpoint string, body interface{}) (req *http.Request, err error) {
buffer := bytes.NewBuffer([]byte{})
if err = json.NewEncoder(buffer).Encode(body); err != nil {
return nil, err
}
- if req, err = http.NewRequest("POST", endpoint, buffer); err != nil {
+ if req, err = http.NewRequestWithContext(ctx, http.MethodPost, endpoint, buffer); err != nil {
return nil, err
}
@@ -184,7 +182,6 @@ func postWithMultipartResponse(ctx context.Context, client httpClient, path, nam
}
req.Header.Add("Content-Type", wr.FormDataContentType())
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
- req = req.WithContext(ctx)
resp, err := client.Do(req)
if err != nil {
@@ -206,7 +203,6 @@ func postWithMultipartResponse(ctx context.Context, client httpClient, path, nam
}
func doPost(ctx context.Context, client httpClient, req *http.Request, parser responseParser, d Debug) error {
- req = req.WithContext(ctx)
resp, err := client.Do(req)
if err != nil {
return err
@@ -224,7 +220,7 @@ func doPost(ctx context.Context, client httpClient, req *http.Request, parser re
// post JSON.
func postJSON(ctx context.Context, client httpClient, endpoint, token string, json []byte, intf interface{}, d Debug) error {
reqBody := bytes.NewBuffer(json)
- req, err := http.NewRequest("POST", endpoint, reqBody)
+ req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, reqBody)
if err != nil {
return err
}
@@ -237,7 +233,7 @@ func postJSON(ctx context.Context, client httpClient, endpoint, token string, js
// post a url encoded form.
func postForm(ctx context.Context, client httpClient, endpoint string, values url.Values, intf interface{}, d Debug) error {
reqBody := strings.NewReader(values.Encode())
- req, err := http.NewRequest("POST", endpoint, reqBody)
+ req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, reqBody)
if err != nil {
return err
}
@@ -246,7 +242,7 @@ func postForm(ctx context.Context, client httpClient, endpoint string, values ur
}
func getResource(ctx context.Context, client httpClient, endpoint, token string, values url.Values, intf interface{}, d Debug) error {
- req, err := http.NewRequest("GET", endpoint, nil)
+ req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil)
if err != nil {
return err
}