feat: add customHeaders closure for injecting request headers#103
Open
chocke wants to merge 1 commit intoFlagsmith:mainfrom
Open
feat: add customHeaders closure for injecting request headers#103chocke wants to merge 1 commit intoFlagsmith:mainfrom
chocke wants to merge 1 commit intoFlagsmith:mainfrom
Conversation
Introduces a public customHeaders closure property on Flagsmith that allows consumers to inject arbitrary HTTP headers into every SDK request. The closure is invoked fresh on every request, so dynamic values (OAuth Bearer tokens, request correlation IDs, custom telemetry, etc.) are always up to date. Use cases this unblocks: - Authenticating through a gateway/proxy that requires custom auth headers (e.g. OAuth Bearer) that aren't the X-Environment-Key - Adding tracing/correlation IDs to requests for observability - Injecting A/B testing or user-agent headers for downstream systems Backward compatible — when customHeaders is nil (the default), behavior is unchanged. Changes: - Flagsmith.swift: add public customHeaders closure property - APIManager.swift: invoke closure and apply headers to every request - SSEManager.swift: same for SSE connection requests - CustomHeadersTests.swift: add tests covering invocation, nil, and per-request freshness
e55d1e6 to
0a98a88
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces a public
customHeadersclosure property onFlagsmiththat allows consumers to inject arbitrary HTTP headers into every SDK request. The closure is invoked fresh on every request, so dynamic values (OAuth Bearer tokens, request correlation IDs, custom telemetry, etc.) are always up to date.Use cases this unblocks:
X-Environment-KeyBackward compatible — when
customHeadersis nil (the default), behavior is unchanged.Changes:
customHeadersclosure property