feat: add custom headers support for HTTP and gRPC sync providers#8
Merged
raflFaisal merged 2 commits intobooking-mainfrom Apr 30, 2026
Merged
feat: add custom headers support for HTTP and gRPC sync providers#8raflFaisal merged 2 commits intobooking-mainfrom
raflFaisal merged 2 commits intobooking-mainfrom
Conversation
remove extra blank line Signed-off-by: faisal.rafi <[email protected]>
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.
Summary
Add support for custom headers in HTTP and gRPC sync providers, configurable globally via CLI flag and per-source in JSON configuration.
Problem
flagd's sync providers cannot inject custom request headers into outbound requests. This limits integration with environments where intermediaries (API gateways, reverse proxies, service meshes) require specific headers for routing, tenant identification, or policy enforcement, resulting in errors like 421 Misdirected Request or misrouting.
Solution
CLI flag: --sync-headers="Key=Value,Key2=Value2" injects headers into all sync requests globally.
Per-source config: "headers": {"Key": "Value"} in the source JSON for fine-grained control.
flagd start --sources='[{"uri":"https://proxy-gateway.xyz.com/flags/sync","provider":"http","headers":{"X-Proxy-Gateway-Host":"backend-api.service"}}]'Global config:
flagd start --sync-headers="X-Proxy-Gateway-Host=backend-api.service" --sources='[{"uri":"https://interop-gateway.bk-eu-west6.service-mesh.dqs.booking.com/flags/sync","provider":"http"}]'Precedence: Per-source values override global values when keys conflict.
Headers are sent as HTTP request headers for HTTP sync and as gRPC metadata for gRPC sync.
Examples:
Global + per-source with precedence (HTTP):
→ X-Tenant-ID=tenant1 from global, X-Gateway-Host=override-host from per-source (wins over global).
gRPC with per-source headers:
Scope & compatibility
Fully backward compatible, headers are optional and default to empty
No behavior change for existing configurations
Covers both HTTP and gRPC sync providers
Test plan
Unit tests for HTTP sync header injection
Unit tests for gRPC sync metadata injection
Builder tests for header merging/precedence logic