Skip to content

Commit

Permalink
Add http headers to the api client (#3394)
Browse files Browse the repository at this point in the history
  • Loading branch information
msoderberg authored and jefferai committed Oct 6, 2017
1 parent 44e0def commit af3022b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ type Client struct {
addr *url.URL
config *Config
token string
headers http.Header
wrappingLookupFunc WrappingLookupFunc
}

Expand Down Expand Up @@ -350,6 +351,11 @@ func (c *Client) ClearToken() {
c.token = ""
}

// SetHeaders sets the headers to be used for future requests.
func (c *Client) SetHeaders(headers http.Header) {
c.headers = headers
}

// Clone creates a copy of this client.
func (c *Client) Clone() (*Client, error) {
return NewClient(c.config)
Expand Down Expand Up @@ -399,6 +405,9 @@ func (c *Client) NewRequest(method, requestPath string) *Request {
if c.config.Timeout != 0 {
c.config.HttpClient.Timeout = c.config.Timeout
}
if c.headers != nil {
req.Headers = c.headers
}

return req
}
Expand Down

0 comments on commit af3022b

Please sign in to comment.