pub struct Finalizer;Expand description
Converts a ReplyData into a concrete hyper HTTP response — setting
status, headers, and body, and driving buffered, streaming, SSE, and
connection-upgrade replies.
Implementations§
Source§impl Finalizer
impl Finalizer
Sourcepub fn build_response<'a>(
&'a self,
data: ReplyData,
) -> BoxFuture<'a, Response<BoxBody<Bytes, WebError>>>
pub fn build_response<'a>( &'a self, data: ReplyData, ) -> BoxFuture<'a, Response<BoxBody<Bytes, WebError>>>
Build the hyper response for data — its status line, headers, and
body (buffered, streaming, SSE, or a connection upgrade).
Sourcepub fn error_to_reply(&self, error: WebError) -> ReplyData
pub fn error_to_reply(&self, error: WebError) -> ReplyData
Convert a WebError into a ReplyData carrying the canonical
application/problem+json body (per RFC 7807), the appropriate
status, and any error-specific headers (e.g. Allow for 405).
Use this when you want an error to flow through the same response
pipeline as a handler success — after-chain middleware, compression,
CORS. The simple variants (NotFound, BadRequest, …) map to obvious
status/title pairs; Problem(p) preserves extension members; the
returned reply is a ReplyData::Rich so an after hook can stamp
headers or replace the status without manual juggling.
Sourcepub async fn build_error(
&self,
error: WebError,
) -> Response<BoxBody<Bytes, WebError>>
pub async fn build_error( &self, error: WebError, ) -> Response<BoxBody<Bytes, WebError>>
Build a complete error Response directly — the one-shot
error → response path used for fallback paths (after-chain failures
while finalizing an error reply, etc.) where running the error
through the after-chain would risk recursion. For the normal error
path, prefer Finalizer::error_to_reply + Finalizer::build_response
so middleware / compression / CORS apply uniformly.