Skip to content

Commit 3bcb4a6

Browse files
fix: Prevent unexpected warning from Resty when calling Client.SetDebug(false) (#508)
1 parent 30da20d commit 3bcb4a6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

client.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ func (c *Client) R(ctx context.Context) *resty.Request {
122122
func (c *Client) SetDebug(debug bool) *Client {
123123
c.debug = debug
124124
c.resty.SetDebug(debug)
125-
// this ensures that if there is an Authorization header present, the value is sanitized/masked
126-
c.sanitizeAuthorizationHeader()
127125

128126
return c
129127
}
@@ -414,12 +412,14 @@ func (c *Client) SetHeader(name, value string) {
414412
c.resty.SetHeader(name, value)
415413
}
416414

417-
func (c *Client) sanitizeAuthorizationHeader() {
415+
func (c *Client) enableLogSanitization() *Client {
418416
c.resty.OnRequestLog(func(r *resty.RequestLog) error {
419417
// masking authorization header
420418
r.Header.Set("Authorization", "Bearer *******************************")
421419
return nil
422420
})
421+
422+
return c
423423
}
424424

425425
// NewClient factory to create new Client struct
@@ -468,7 +468,8 @@ func NewClient(hc *http.Client) (client Client) {
468468
SetRetryWaitTime(APISecondsPerPoll * time.Second).
469469
SetPollDelay(APISecondsPerPoll * time.Second).
470470
SetRetries().
471-
SetDebug(envDebug)
471+
SetDebug(envDebug).
472+
enableLogSanitization()
472473

473474
return
474475
}

0 commit comments

Comments
 (0)