diff options
| author | Stefan Majewsky <stefan.majewsky@sap.com> | 2024-07-08 15:43:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-08 15:43:52 +0200 |
| commit | 4fac97b5e944ce70cdca3679f5c2b1eef9b83952 (patch) | |
| tree | fcf486f49df855f2803981c753ed775b1305f6c8 /request.go | |
| parent | 5a783c56a98c225569abfa6fb12fdf55297fee9e (diff) | |
| parent | b7683ab8dcdeca10ff52d626a285edcf7c1db719 (diff) | |
| download | go-schwift-4fac97b5e944ce70cdca3679f5c2b1eef9b83952.tar.gz | |
Merge pull request #19 from SuperSandro2000/context
Remove context from struct, add ctx as first args to many functions
Diffstat (limited to 'request.go')
| -rw-r--r-- | request.go | 9 |
1 files changed, 2 insertions, 7 deletions
@@ -40,7 +40,6 @@ import ( type RequestOptions struct { Headers Headers Values url.Values - Context context.Context //nolint: containedctx // ignored for now to not break the API } func cloneRequestOptions(orig *RequestOptions, additional Headers) *RequestOptions { @@ -55,7 +54,6 @@ func cloneRequestOptions(orig *RequestOptions, additional Headers) *RequestOptio for k, v := range orig.Values { result.Values[k] = v } - result.Context = orig.Context } for k, v := range additional { result.Headers[k] = v @@ -106,7 +104,7 @@ func (r Request) URL(backend Backend, values url.Values) (string, error) { } // Do executes this request on the given Backend. -func (r Request) Do(backend Backend) (*http.Response, error) { +func (r Request) Do(ctx context.Context, backend Backend) (*http.Response, error) { // build URL var values url.Values if r.Options != nil { @@ -118,7 +116,7 @@ func (r Request) Do(backend Backend) (*http.Response, error) { } // build request - req, err := http.NewRequest(r.Method, uri, r.Body) + req, err := http.NewRequestWithContext(ctx, r.Method, uri, r.Body) if err != nil { return nil, err } @@ -127,9 +125,6 @@ func (r Request) Do(backend Backend) (*http.Response, error) { for k, v := range r.Options.Headers { req.Header[k] = []string{v} } - if r.Options.Context != nil { - req = req.WithContext(r.Options.Context) - } } if r.Body != nil { req.Header.Set("Expect", "100-continue") |
