From c8d3e5f9ca71f536e2a63492c6cd690a347a660e Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sat, 23 Aug 2025 10:31:40 +0200 Subject: [PATCH] Don't use the default client for requestcached --- main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 90aa3aa..6b70e26 100644 --- a/main.go +++ b/main.go @@ -96,6 +96,12 @@ func LimitedHttp(rps float64, burst int) *http.Client { } } +var client = http.DefaultClient + +func WithClient(nclient *http.Client) { + client = nclient +} + func RequestCached[T any](req *http.Request, filename string) (T, error) { var zero T @@ -105,7 +111,7 @@ func RequestCached[T any](req *http.Request, filename string) (T, error) { return zero, fmt.Errorf("failed to read cache: %w", err) } - resp, httpErr := http.DefaultClient.Do(req) + resp, httpErr := client.Do(req) if httpErr != nil { return zero, fmt.Errorf("HTTP request failed: %w", httpErr) }