pub trait Responder {
// Required method
fn response_to(self, req: &RequestContext<'_, '_>) -> Response<ResponseBody>;
}Expand description
A trait for types that can be converted into HTTP responses.
Types implementing this trait can be returned directly from request handlers and will be automatically converted into HTTP responses.
Required Methods§
fn response_to(self, req: &RequestContext<'_, '_>) -> Response<ResponseBody>
Implementations on Foreign Types§
Source§impl Responder for &'static str
Implementation for static strings returns them as plain text responses.
impl Responder for &'static str
Implementation for static strings returns them as plain text responses.
fn response_to(self, _req: &RequestContext<'_, '_>) -> Response<ResponseBody>
Source§impl Responder for Infallible
impl Responder for Infallible
fn response_to(self, _req: &RequestContext<'_, '_>) -> Response<ResponseBody>
Source§impl Responder for ParseError
Responder implementation for ParseError to convert parsing errors to responses
impl Responder for ParseError
Responder implementation for ParseError to convert parsing errors to responses
fn response_to(self, req: &RequestContext<'_, '_>) -> Response<ResponseBody>
Source§impl Responder for ()
Implementation for unit type () returns an empty response.
impl Responder for ()
Implementation for unit type () returns an empty response.
fn response_to(self, _req: &RequestContext<'_, '_>) -> Response<ResponseBody>
Source§impl Responder for String
Implementation for String returns it as a plain text response.
impl Responder for String
Implementation for String returns it as a plain text response.
fn response_to(self, _req: &RequestContext<'_, '_>) -> Response<ResponseBody>
Source§impl<B> Responder for Response<B>where
B: Into<ResponseBody>,
Implementation for Response allows passing through pre-built responses.
The response body is converted to the internal ResponseBody type.
impl<B> Responder for Response<B>where
B: Into<ResponseBody>,
Implementation for Response allows passing through pre-built responses. The response body is converted to the internal ResponseBody type.
fn response_to(self, _req: &RequestContext<'_, '_>) -> Response<ResponseBody>
Source§impl<T: Responder> Responder for (StatusCode, T)
Implementation for (StatusCode, T) tuple allows setting a status code
along with the response content.
impl<T: Responder> Responder for (StatusCode, T)
Implementation for (StatusCode, T) tuple allows setting a status code along with the response content.
fn response_to(self, req: &RequestContext<'_, '_>) -> Response<ResponseBody>
Source§impl<T: Responder> Responder for (T, StatusCode)
Implementation for (T, StatusCode) tuple - same as above but with reversed order.
impl<T: Responder> Responder for (T, StatusCode)
Implementation for (T, StatusCode) tuple - same as above but with reversed order.
fn response_to(self, req: &RequestContext<'_, '_>) -> Response<ResponseBody>
Source§impl<T: Responder> Responder for Option<T>
Implementation for Option allows handlers to return Option types.
None case returns an empty response.
impl<T: Responder> Responder for Option<T>
Implementation for Option allows handlers to return Option types. None case returns an empty response.
fn response_to(self, req: &RequestContext<'_, '_>) -> Response<ResponseBody>
Source§impl<T: Responder> Responder for Box<T>
Implementation for Box allows boxing responders.
impl<T: Responder> Responder for Box<T>
Implementation for Box
fn response_to(self, req: &RequestContext<'_, '_>) -> Response<ResponseBody>
Source§impl<T: Responder, E: Responder> Responder for Result<T, E>
Implementation for Result allows handlers to return Result types directly.
The Ok and Err variants must both implement Responder.
impl<T: Responder, E: Responder> Responder for Result<T, E>
Implementation for Result allows handlers to return Result types directly. The Ok and Err variants must both implement Responder.