Repository navigation
fix: apply custom_headers to API client requests #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,13 +30,23 @@ def initialize(config) | |
| def build_headers(faraday, config) | ||
| faraday.headers['Accept'] = 'application/json' | ||
| faraday.headers['Content-Type'] = 'application/json' | ||
| faraday.headers['X-Environment-Key'] = config.environment_key | ||
| faraday.headers['User-Agent'] = Flagsmith::SDK::Utils.user_agent | ||
| faraday.headers.merge(config.custom_headers) | ||
| faraday.headers.merge!(config.custom_headers) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep custom credentials out of request logs. With the default logger, a request now logs the configured Apply one precedence rule to
Choose one rule for conflicting |
||
| # Set last, so custom_headers cannot replace it (same as the events API). | ||
| faraday.headers['X-Environment-Key'] = config.environment_key | ||
| end | ||
|
|
||
| def configure_logger(faraday, config) | ||
| faraday.response :logger, config.logger | ||
| faraday.response :logger, config.logger do |formatter| | ||
| redact_custom_headers(formatter, config) | ||
| end | ||
| end | ||
|
|
||
| # custom_headers often carry credentials, keep their values out of the logs. | ||
| def redact_custom_headers(formatter, config) | ||
| Faraday::Utils::Headers.new.update(config.custom_headers).each_key do |name| | ||
| formatter.filter(/^(#{Regexp.escape(name)}: ).*$/i, '\1"[REDACTED]"') | ||
| end | ||
| end | ||
|
|
||
| def configure_retries(faraday, config) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.