Skip to content

Commit

Permalink
document that some headers can't be set by WithHeader
Browse files Browse the repository at this point in the history
  • Loading branch information
ghouscht committed Mar 21, 2018
1 parent d1f17ef commit f7d4773
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func WithContentType(ct string) Opt {
}

// WithHeader is a client option for setting custom http header(s) for each request
// Content-Type and Accept headers will always be overwritten by the clients ContentType setting
func WithHeader(header http.Header) Opt {
return func(c *Client) error {
c.header = header
Expand Down
4 changes: 3 additions & 1 deletion httpclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ func TestClient(t *testing.T) {

req, err := c.NewRequest(http.MethodGet, "/test", nil)
assert.Nil(t, err)
assert.Equal(t, req.Header, customHeader)
assert.Equal(t, req.Header["X-Requested-By"], []string{"test"})
assert.Contains(t, req.Header, "Content-Type")
assert.Contains(t, req.Header, "Accept")
})

t.Run("new client valid baseurl valid HTTP client", func(t *testing.T) {
Expand Down

0 comments on commit f7d4773

Please sign in to comment.