Skip to content

Commit

Permalink
Move mutator to the end
Browse files Browse the repository at this point in the history
  • Loading branch information
loafoe committed May 14, 2022
1 parent 68e399c commit c07fe78
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions iam/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,23 +446,14 @@ func (c *Client) newRequest(endpoint, method, path string, opt interface{}, opti
}
req.Header.Set("User-Agent", userAgent)

for _, fn := range options {
if fn == nil {
continue
}

if err := fn(req); err != nil {
return nil, err
}
}

if method == "POST" || method == "PUT" {
bodyBytes, err := json.Marshal(opt)
if err != nil {
return nil, err
}
bodyReader := bytes.NewReader(bodyBytes)

u.RawQuery = ""
req.Body = ioutil.NopCloser(bodyReader)
req.ContentLength = int64(bodyReader.Len())
req.Header.Set("Content-Type", "application/json")
Expand All @@ -478,6 +469,15 @@ func (c *Client) newRequest(endpoint, method, path string, opt interface{}, opti
req.Header.Set("X-Token-Error", fmt.Sprintf("%v", err))
}
}
for _, fn := range options {
if fn == nil {
continue
}
if err := fn(req); err != nil {
return nil, err
}
}

return req, nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package internal

const (
LibraryVersion = "0.63.3"
LibraryVersion = "0.63.4"
)

0 comments on commit c07fe78

Please sign in to comment.