Skip to main content

Module response

Module response 

Source
Expand description

Response model. Handlers return anything implementing IntoResponse; Result<T, Error> renders errors as {"code","message"} JSON (spec §4.1).

Structs§

BodyError
Mid-stream body failure. Reaching hyper as a body error aborts the connection, so the client sees a truncated (invalid) chunked stream rather than a clean end — truncation must be detectable.
BodySender
Push side of StreamBody::channel.
Created
201 Created with a JSON body.
JcBody
The response body: a fixed buffer for buffered handlers, or a stream when a handler returns StreamBody (downloads, exports). Wraps a BoxBody so the response type is stable whichever shape the body takes; its error channel is BodyError, which a mid-stream failure rides to abort the connection.
Json
JSON body wrapper: Json(value) serializes with application/json.
NoContent
204 No Content.
Redirect
An HTTP redirect: an empty body plus a Location header and a 3xx status. Use the constructor that names the semantics you want — to/see_other/ temporary/permanent — rather than hand-setting a status code.
StreamBody
A streaming response body: downloads, CSV exports, anything produced incrementally. Defaults: application/octet-stream, 200 OK, 30s frame timeout (a producer that stalls longer aborts the connection).

Traits§

IntoResponse
Conversion of handler return values into HTTP responses.

Type Aliases§

Response
The concrete response type. Streaming bodies ride the same IntoResponse seam as buffered ones, so handler signatures won’t change.