diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2022-01-09 17:12:13 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-09 22:12:13 +0000 |
| commit | 155803de7d5c1df5edd456a45a19008c9ae5ea7b (patch) | |
| tree | 7bdc7501e3450ea2a2fafa2521ff0d6a165a1a0e /data/datasource_http.go | |
| parent | d03538dcbc6f7d22e02c44269b63ff1d54020ed4 (diff) | |
Propagate context into datasource read functions (#1282)
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'data/datasource_http.go')
| -rw-r--r-- | data/datasource_http.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/data/datasource_http.go b/data/datasource_http.go index e809768e..ed1c97b7 100644 --- a/data/datasource_http.go +++ b/data/datasource_http.go @@ -1,6 +1,7 @@ package data import ( + "context" "io/ioutil" "mime" "net/http" @@ -21,7 +22,7 @@ func buildURL(base *url.URL, args ...string) (*url.URL, error) { return base.ResolveReference(p), nil } -func readHTTP(source *Source, args ...string) ([]byte, error) { +func readHTTP(ctx context.Context, source *Source, args ...string) ([]byte, error) { if source.hc == nil { source.hc = &http.Client{Timeout: time.Second * 5} } @@ -29,7 +30,7 @@ func readHTTP(source *Source, args ...string) ([]byte, error) { if err != nil { return nil, err } - req, err := http.NewRequest("GET", u.String(), nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil) if err != nil { return nil, err } |
