aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/net.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-01-03 23:53:52 +0900
committerOphestra <cat@gensokyo.uk>2026-01-03 23:53:52 +0900
commit05202cf99481e4b005d766a1a5fdec5d2889396b (patch)
tree3bf5e8ebaf985cccb867e63e5e52c2a9209597bf /internal/pkg/net.go
parent40081e7a0694db0ebe2b59e7545ecc43128c8f40 (diff)
internal/pkg: pass context in request wrapper
This method is for the most common use case, and in actual use there will always be an associated context. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg/net.go')
-rw-r--r--internal/pkg/net.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/internal/pkg/net.go b/internal/pkg/net.go
index 519a9b0f..09ad7fa0 100644
--- a/internal/pkg/net.go
+++ b/internal/pkg/net.go
@@ -1,6 +1,7 @@
package pkg
import (
+ "context"
"crypto/sha512"
"errors"
"io"
@@ -45,8 +46,13 @@ func (c *Cache) NewHTTP(hc *http.Client, req *http.Request, checksum Checksum) F
// NewHTTPGet returns a new [File] backed by the supplied client. A GET request
// is set up for url. If c is nil, [http.DefaultClient] is used instead.
-func (c *Cache) NewHTTPGet(hc *http.Client, url string, checksum Checksum) (File, error) {
- req, err := http.NewRequest(http.MethodGet, url, nil)
+func (c *Cache) NewHTTPGet(
+ ctx context.Context,
+ hc *http.Client,
+ url string,
+ checksum Checksum,
+) (File, error) {
+ req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
if err != nil {
return nil, err
}