Typed request/response custom headers - #15
Open
aloks98 wants to merge 9 commits into
Open
Conversation
Replace the legacy flat map iteration with the typed CustomHeaders fields: request headers land on Headers.Request (on top of the standard proxy headers) and response headers on Headers.Response. Also fix the remaining Task 1 callers that used the old JSONField/nil shape so the backend builds. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… and schema comment
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
Adds both-direction custom headers to reverse proxies — request headers sent to the upstream and response headers returned to the client. Previously
custom_headerswere applied only as request headers (surfaced by the traffic E2E suite in the base PR).What changed
CustomHeaderstype): flexibleUnmarshalJSONaccepts both the legacy flat map (→ request headers) and the nested{"request":{...},"response":{...}}shape; normalizes to nested on read; GORMScan/Valueso legacy rows load transparently — no DB migration.Headers.Request(layered on standard proxy headers) and response headers toHeaders.Response.models.Proxy); responses return the normalized nested shape.CustomHeaderstype + two key-value editors in the reverse-proxy form ("Request headers to upstream" / "Response headers to client") + fixed the change-detection comparison.custom_headersscenario un-skipped — asserts a response header reaches the client AND a request header reaches the backend.Backward compatibility
A flat
custom_headersmap (existing DB rows and old API clients) keeps working as request headers. Empty serializes as{}(accepted per design).Known follow-up (pre-existing, not in this PR)
custom_headerschanges aren't recorded in the proxy audit log (the old flat headers weren't either).Test plan
go test ./backend/internal/models/ ./backend/internal/caddy/config/ -count=1— greenmake test-traffic—custom_headerspasses both directions (no skip)pnpm --dir ui build+make lint-ui— green🤖 Generated with Claude Code