From 295454333a6fdd174acc372d782866075adcf97d Mon Sep 17 00:00:00 2001 From: frrist Date: Fri, 26 Jan 2024 12:26:04 -0800 Subject: [PATCH] fixup! refactor: rename client config --- pkg/publicapi/client/v2/client.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/publicapi/client/v2/client.go b/pkg/publicapi/client/v2/client.go index 8cdfe9bdba..222213280b 100644 --- a/pkg/publicapi/client/v2/client.go +++ b/pkg/publicapi/client/v2/client.go @@ -11,7 +11,7 @@ import ( type Client struct { httpClient *http.Client - options Config + config Config } // New creates a new client. @@ -23,7 +23,7 @@ func New(cfg Config, optFns ...OptionFn) *Client { resolveHTTPClient(&cfg) return &Client{ httpClient: cfg.HTTPClient, - options: cfg, + config: cfg, } } @@ -120,8 +120,8 @@ func (c *Client) toHTTP(ctx context.Context, method, endpoint string, r *apimode } // build parameters - if c.options.Namespace != "" && r.Params.Get("namespace") == "" { - r.Params.Add("namespace", c.options.Namespace) + if c.config.Namespace != "" && r.Params.Get("namespace") == "" { + r.Params.Add("namespace", c.config.Namespace) } // Add in the query parameters, if any for key, values := range u.Query() { @@ -154,17 +154,17 @@ func (c *Client) toHTTP(ctx context.Context, method, endpoint string, r *apimode if contentType != "" { req.Header.Set("Content-Type", contentType) } - if c.options.AppID != "" { - req.Header.Set(apimodels.HTTPHeaderAppID, c.options.AppID) - req.Header.Add("User-Agent", c.options.AppID) + if c.config.AppID != "" { + req.Header.Set(apimodels.HTTPHeaderAppID, c.config.AppID) + req.Header.Add("User-Agent", c.config.AppID) } // Optionally configure HTTP authorization - if c.options.HTTPAuth != nil { - req.Header.Set("Authorization", c.options.HTTPAuth.String()) + if c.config.HTTPAuth != nil { + req.Header.Set("Authorization", c.config.HTTPAuth.String()) } - for key, values := range c.options.Headers { + for key, values := range c.config.Headers { for _, value := range values { req.Header.Add(key, value) } @@ -178,7 +178,7 @@ func (c *Client) toHTTP(ctx context.Context, method, endpoint string, r *apimode // generate URL for a given endpoint func (c *Client) url(endpoint string) (*url.URL, error) { - base, _ := url.Parse(c.options.Address) + base, _ := url.Parse(c.config.Address) u, err := url.Parse(endpoint) if err != nil { return nil, err