From de9e72e1dc6961f6b6ed3fe9cf4381344dd5fa37 Mon Sep 17 00:00:00 2001 From: Eno Compton Date: Thu, 11 Nov 2021 11:48:26 -0700 Subject: [PATCH] feat: add support for configuring the HTTP client (#55) Fixes #54. --- options.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/options.go b/options.go index 2564a9b5..4409fe41 100644 --- a/options.go +++ b/options.go @@ -18,6 +18,7 @@ import ( "context" "crypto/rsa" "io/ioutil" + "net/http" "time" "cloud.google.com/go/cloudsqlconn/errtypes" @@ -110,6 +111,15 @@ func WithRefreshTimeout(t time.Duration) DialerOption { } } +// WithHTTPClient configures the underlying SQL Admin API client with the +// provided HTTP client. This option is generally unnecessary except for +// advanced use-cases. +func WithHTTPClient(client *http.Client) DialerOption { + return func(d *dialerConfig) { + d.sqladminOpts = append(d.sqladminOpts, apiopt.WithHTTPClient(client)) + } +} + // WithIAMAuthN enables automatic IAM Authentication. If no token source has // been configured (such as with WithTokenSource, WithCredentialsFile, etc), the // dialer will use the default token source as defined by