Skip to content

feat: add custom headers support for HTTP and gRPC sync providers#8

Merged
raflFaisal merged 2 commits intobooking-mainfrom
feat/custom-headers-sync
Apr 30, 2026
Merged

feat: add custom headers support for HTTP and gRPC sync providers#8
raflFaisal merged 2 commits intobooking-mainfrom
feat/custom-headers-sync

Conversation

@raflFaisal
Copy link
Copy Markdown

@raflFaisal raflFaisal commented Apr 30, 2026

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):

flagd start \
  --sync-headers="X-Tenant-ID=tenant1,X-Gateway-Host=default-host" \
  --sources='[{"uri":"http://my-flags.com/flags","provider":"http","headers":{"X-Gateway-Host":"override-host"}}]'

→ X-Tenant-ID=tenant1 from global, X-Gateway-Host=override-host from per-source (wins over global).

gRPC with per-source headers:

flagd start \
  --sources='[{"uri":"proxy-gateway-server.xyz.com","provider":"grpc","selector":"features","headers":{"X-Routing-Target-Host":"b.flags-server.service"}}]'

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

faisalBooking and others added 2 commits May 1, 2026 00:02
remove extra blank line

Signed-off-by: faisal.rafi <faisal.rafi.mca@gmail.com>
@raflFaisal raflFaisal merged commit 679185d into booking-main Apr 30, 2026
9 checks passed
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.

2 participants