Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add extensible header configuration #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 12 additions & 4 deletions lib/novu.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ type RetryConfigType struct {
}

type Config struct {
BackendURL *url.URL
HttpClient *http.Client
RetryConfig *RetryConfigType
BackendURL *url.URL
HttpClient *http.Client
HttpClientHeaders map[string]string
RetryConfig *RetryConfigType
}

type APIClient struct {
Expand All @@ -51,7 +52,7 @@ type APIClient struct {
IntegrationsApi *IntegrationService
InboundParserApi *InboundParserService
LayoutApi *LayoutService
TenantApi *TenantService
TenantApi *TenantService
}

type service struct {
Expand Down Expand Up @@ -120,6 +121,13 @@ func (c APIClient) sendRequest(req *http.Request, resp interface{}) (*http.Respo
req.Header.Set("Authorization", fmt.Sprintf("ApiKey %s", c.apiKey))
req.Header.Set("Idempotency-Key", uuid.New().String())

headers := c.config.HttpClientHeaders
if headers != nil {
for header, value := range headers {
req.Header.Set(header, value)
}
}

res, err := c.config.HttpClient.Do(req)
if err != nil {
return res, errors.Wrap(err, "failed to execute request")
Expand Down