Skip to content

Commit 0ee262b

Browse files
committed
feat: use context in HTTP loader
1 parent b41762f commit 0ee262b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

httploader/httploader.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// registering its Loaders.
99
//
1010
// To use httploader, link this package into your program:
11-
// import _ "github.com/ory/jsonschema/v3/httploader"
1211
//
12+
// import _ "github.com/ory/jsonschema/v3/httploader"
1313
package httploader
1414

1515
import (
@@ -38,7 +38,12 @@ func Load(ctx context.Context, url string) (io.ReadCloser, error) {
3838
return nil, fmt.Errorf("invalid context value for %s expected %T but got: %T", ContextKey, new(retryablehttp.Client), v)
3939
}
4040

41-
resp, err := hc.Get(url)
41+
req, err := retryablehttp.NewRequest("GET", url, nil)
42+
if err != nil {
43+
return nil, err
44+
}
45+
req = req.WithContext(ctx)
46+
resp, err := hc.Do(req)
4247
if err != nil {
4348
return nil, err
4449
}

0 commit comments

Comments
 (0)