Skip to content

Response headers

Response headers declared on a response in the spec are surfaced on a generated …Headers struct, one per response variant that declares headers, with one field per header. The handler sets the values it wants returned; the generated IntoResponse impl writes them onto the response.

Header schemaGenerated fieldSerialization
Scalar (string, integer, number, boolean, date, date-time, UUID)T (or Option<T> if not required)the value’s text form
Array of scalarsVec<T> (or Option<Vec<T>>)OpenAPI simple style, comma-joined (X-Ids: 1,2,3)

Object and map (additionalProperties) header values are rejected at generation time with a clear error. Support for them is tracked in #122.

If you need a structured value in a single header today, declare the header as type: string and format the payload (for example, JSON) in your handler.