Skip to content

Commit

Permalink
Set the User-Agent during client creation and not on each request (#3890
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jtopjian authored Jul 9, 2020
1 parent 97e379b commit ae485d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Versioning](http://semver.org/spec/v2.0.0.html).
### Fixed
- Clarifies wording around a secret provider error message.
- Logs and returns an error if a mutator cannot be found.
- User-Agent header is only set on new client creation rather than on each
request.

### Breaking
- The database schema for entities has changed. After upgrading, users will not
Expand Down
5 changes: 3 additions & 2 deletions cli/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ func New(config config.Config) *RestClient {
restyInst.SetHeader("Accept", "application/json")
restyInst.SetHeader("Content-Type", "application/json")

// Set the User-Agent header
restyInst.SetHeader("User-Agent", "sensuctl/"+version.Semver())

// Check that Access-Token has not expired
restyInst.OnBeforeRequest(func(c *resty.Client, r *resty.Request) error {
c.SetHeader("User-Agent", "sensuctl/"+version.Semver())

// Guard against requests that are not sending auth details
if c.Token == "" || r.UserInfo != nil {
return nil
Expand Down

0 comments on commit ae485d8

Please sign in to comment.