Skip to content

Commit

Permalink
Merge pull request #138 from zreigz/fix-HTTPRequestOption-header
Browse files Browse the repository at this point in the history
prevent overwrite Header by HTTPRequestOption function
  • Loading branch information
Yamashou committed Jul 16, 2022
2 parents 0aa639d + 039af83 commit de74cd1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client/client.go
Expand Up @@ -55,6 +55,9 @@ func (c *Client) newRequest(ctx context.Context, operationName, query string, va
return nil, fmt.Errorf("create request struct failed: %w", err)
}

req.Header.Set("Content-Type", "application/json; charset=utf-8")
req.Header.Set("Accept", "application/json; charset=utf-8")

for _, httpRequestOption := range c.HTTPRequestOptions {
httpRequestOption(req)
}
Expand Down Expand Up @@ -109,8 +112,6 @@ func (c *Client) Post(ctx context.Context, operationName, query string, respData
if err != nil {
return fmt.Errorf("don't create request: %w", err)
}
req.Header.Set("Content-Type", "application/json; charset=utf-8")
req.Header.Set("Accept", "application/json; charset=utf-8")

resp, err := c.Client.Do(req)
if err != nil {
Expand Down

0 comments on commit de74cd1

Please sign in to comment.