Skip to content

feat: add customHeaders closure for injecting request headers#103

Open
chocke wants to merge 1 commit intoFlagsmith:mainfrom
chocke:feat/custom-headers
Open

feat: add customHeaders closure for injecting request headers#103
chocke wants to merge 1 commit intoFlagsmith:mainfrom
chocke:feat/custom-headers

Conversation

@chocke
Copy link
Copy Markdown

@chocke chocke commented Apr 13, 2026

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

@chocke chocke requested a review from a team as a code owner April 13, 2026 11:47
@chocke chocke requested review from Zaimwa9 and removed request for a team April 13, 2026 11:47
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
@chocke chocke force-pushed the feat/custom-headers branch from e55d1e6 to 0a98a88 Compare April 13, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant