Skip to content

Commit

Permalink
fixup! refactor: rename client config
Browse files Browse the repository at this point in the history
  • Loading branch information
frrist committed Jan 26, 2024
1 parent a3d8543 commit 2954543
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pkg/publicapi/client/v2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

type Client struct {
httpClient *http.Client
options Config
config Config
}

// New creates a new client.
Expand All @@ -23,7 +23,7 @@ func New(cfg Config, optFns ...OptionFn) *Client {
resolveHTTPClient(&cfg)
return &Client{
httpClient: cfg.HTTPClient,
options: cfg,
config: cfg,
}
}

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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)
}
Expand All @@ -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
Expand Down

0 comments on commit 2954543

Please sign in to comment.