Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cli/internal/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ func NewClient(host, apiKey string) *Client {
}

func (c *Client) RequestJSON(ctx context.Context, method, path string, query url.Values, body any, out any) error {
return c.RequestJSONWithHeaders(ctx, method, path, query, nil, body, out)
}

func (c *Client) RequestJSONWithHeaders(ctx context.Context, method, path string, query url.Values, customHeaders map[string]string, body any, out any) error {
endpoint := c.Host + path
if len(query) > 0 {
endpoint += "?" + query.Encode()
Expand All @@ -72,6 +76,9 @@ func (c *Client) RequestJSON(ctx context.Context, method, path string, query url
if c.APIKey != "" {
headers["x-api-key"] = c.APIKey
}
for key, value := range customHeaders {
headers[key] = value
}
return JSON(ctx, c.HTTPClient, method, endpoint, headers, body, out)
}

Expand Down
Loading
Loading