From d55380ce4848c2a510aae416ac6c4f0afbc5bc11 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 8 Sep 2026 22:15:42 -0600 Subject: [PATCH] feat(gsheet2csv): add context and custom client options --- io/transform/gsheet2csv/gsheet2csv.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/io/transform/gsheet2csv/gsheet2csv.go b/io/transform/gsheet2csv/gsheet2csv.go index a1b9a14..75b0337 100644 --- a/io/transform/gsheet2csv/gsheet2csv.go +++ b/io/transform/gsheet2csv/gsheet2csv.go @@ -51,8 +51,13 @@ type Reader struct { // NewReaderFromContext is NewReaderFrom with request cancellation. func NewReaderFromContext(ctx context.Context, urlOrPath string) *Reader { + return NewReaderFromContextWith(ctx, httpClient, urlOrPath) +} + +// NewReaderFromContextWith is NewReaderFromContext with a custom HTTP client. +func NewReaderFromContextWith(ctx context.Context, client *http.Client, urlOrPath string) *Reader { if strings.HasPrefix(urlOrPath, "https://") || strings.HasPrefix(urlOrPath, "http://") { - return NewReaderFromURLContext(ctx, urlOrPath) + return NewReaderFromURLWith(ctx, client, urlOrPath) } return NewReaderFrom(urlOrPath) } @@ -74,8 +79,13 @@ func NewReaderFrom(urlOrPath string) *Reader { } func NewReaderFromURLContext(ctx context.Context, url string) *Reader { + return NewReaderFromURLWith(ctx, httpClient, url) +} + +// NewReaderFromURLWith is NewReaderFromURLContext with a custom HTTP client. +func NewReaderFromURLWith(ctx context.Context, client *http.Client, url string) *Reader { docid, gid := ParseIDs(url) - return NewReaderFromIDsContext(ctx, httpClient, docid, gid) + return NewReaderFromIDsContext(ctx, client, docid, gid) } func NewReaderFromURL(url string) *Reader {