Skip to content

Commit

Permalink
Support custom headers in Config (#21)
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Gough <[email protected]>

Signed-off-by: Philip Gough <[email protected]>
  • Loading branch information
philipgough authored Nov 15, 2022
1 parent 3c375b7 commit 191dd1b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions remote_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ type Client struct {
}

type Config struct {
Url string `json:"url"`
UserAgent string `json:"user_agent"`
Timeout string `json:"timeout"`
TenantName string `json:"tenant_name"`
Url string `json:"url"`
UserAgent string `json:"user_agent"`
Timeout string `json:"timeout"`
TenantName string `json:"tenant_name"`
Headers map[string]string `json:"headers"`
}

// xclient represents
Expand Down Expand Up @@ -253,6 +254,12 @@ func (c *Client) send(state *lib.State, req []byte) (httpext.Response, error) {
if err != nil {
return *httpResp, err
}

for k, v := range c.cfg.Headers {
r.Header.Set(k, v)
}

// explicit config overwrites any previously set matching headers
r.Header.Add("Content-Encoding", "snappy")
r.Header.Set("Content-Type", "application/x-protobuf")
r.Header.Set("User-Agent", c.cfg.UserAgent)
Expand Down

0 comments on commit 191dd1b

Please sign in to comment.