Repository navigation
feat(server): generate typed response headers - #115
Merged
Merged
Conversation
Response Objects with declared headers now produce a
{Enum}{Variant}Headers struct as the variant's last field and
into_response appends each value as its own header line.
Set-Cookie is always multi-value per RFC 9110 section 5.3;
a declared Content-Type stays ignored per the specification.
|
@ToyVo is attempting to deploy a commit to the lbl-rd Team on Vercel. A member of the Team first needs to authorize it. |
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
Implements #114
Response Objects with declared headers were silently dropped from generated Axum servers, leaving session-cookie flows (sign-in sets Set-Cookie, logout clears it) with nowhere to put headers in the typed response enums.
This generates a {Enum}{Variant}Headers struct per response that declares headers and threads it through as the variant's last field; into_response appends each value as its own header line, and an invalid value yields a 500. Semantics:
Also fixes string cookie parameters in generated clients (.as_ref() — they're impl AsRef, not Display, so any operation with one previously failed to compile).
Tests: new tests/server_response_headers_test.rs (3 tests) and tests/client_cookie_param_test.rs (1 test) — all pass. Validated end to end against a real auth API over the typed headers.
Generated compatibility
Validation
cargo fmt --checkcargo clippy --all-features -- -D warningscargo test --all-featuresscripts/install-smoke.shfor packaging/dependency changes.scripts/spec-compile.shfor generator changes.Notes for reviewers
Smallest review path: tests/server_response_headers_test.rs first (pins the contract: collection sans Content-Type, invalid-name rejection, variants carry and emit headers incl. the Set-Cookie multi-line case), then response_headers_plan in src/server/codegen.rs, then the analysis.rs collector. Known judgment call: an unencodable header value returns 500 rather than failing generation — headers are runtime data, so generation can't validate values. Deliberately deferred: request-header validation and trailer support; also the client_cookie_param_test.rs fix (string cookies via .as_ref()) rides along as it's the same cookie story on the client side.