Skip to content

Commit

Permalink
Merge pull request #6 from getamis/refine-buildSigHeaderFn-2
Browse files Browse the repository at this point in the history
graphql: builder header func for runWithJSON
  • Loading branch information
markya0616 authored Sep 19, 2022
2 parents b8a3fcf + e8ee9b1 commit e27479b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ func (c *Client) runWithJSON(ctx context.Context, req *Request, resp interface{}
r.Close = c.closeReq
r.Header.Set("Content-Type", "application/json; charset=utf-8")
r.Header.Set("Accept", "application/json; charset=utf-8")
if c.buildHeaderFunc != nil {
for key, values := range c.buildHeaderFunc(requestBody.String()) {
for _, value := range values {
r.Header.Add(key, value)
}
}
}
for key, values := range req.Header {
for _, value := range values {
r.Header.Add(key, value)
Expand Down Expand Up @@ -244,7 +251,6 @@ func (c *Client) runWithPostFields(ctx context.Context, req *Request, resp inter
r.Header.Add(key, value)
}
}

}
c.logf(">> headers: %v", r.Header)
r = r.WithContext(ctx)
Expand Down

0 comments on commit e27479b

Please sign in to comment.