Struct axum::handler::Layered [−][src]
pub struct Layered<S, T> { /* fields omitted */ }
Expand description
A Service
created from a Handler
by applying a Tower middleware.
Created with Handler::layer
. See that method for more details.
Implementations
pub fn handle_error<F, ReqBody, ResBody, Res, E>(
self,
f: F
) -> Layered<HandleError<S, F, ReqBody>, T> where
S: Service<Request<ReqBody>, Response = Response<ResBody>>,
F: FnOnce(S::Error) -> Result<Res, E>,
Res: IntoResponse,
pub fn handle_error<F, ReqBody, ResBody, Res, E>(
self,
f: F
) -> Layered<HandleError<S, F, ReqBody>, T> where
S: Service<Request<ReqBody>, Response = Response<ResBody>>,
F: FnOnce(S::Error) -> Result<Res, E>,
Res: IntoResponse,
Create a new Layered
handler where errors will be handled using the
given closure.
This is used to convert errors to responses rather than simply terminating the connection.
It works similarly to routing::Layered::handle_error
. See that for more details.
Trait Implementations
impl<S, T, ReqBody, ResBody> Handler<ReqBody, T> for Layered<S, T> where
S: Service<Request<ReqBody>, Response = Response<ResBody>> + Send,
S::Error: IntoResponse,
S::Future: Send,
ReqBody: Send + 'static,
ResBody: Body<Data = Bytes> + Send + Sync + 'static,
ResBody::Error: Into<BoxError> + Send + Sync + 'static,
impl<S, T, ReqBody, ResBody> Handler<ReqBody, T> for Layered<S, T> where
S: Service<Request<ReqBody>, Response = Response<ResBody>> + Send,
S::Error: IntoResponse,
S::Future: Send,
ReqBody: Send + 'static,
ResBody: Body<Data = Bytes> + Send + Sync + 'static,
ResBody::Error: Into<BoxError> + Send + Sync + 'static,
type Sealed = Hidden
Call the handler with the given request.
Apply a tower::Layer
to the handler. Read more
Convert the handler into a Service
.
Auto Trait Implementations
impl<S, T> RefUnwindSafe for Layered<S, T> where
S: RefUnwindSafe,
impl<S, T> UnwindSafe for Layered<S, T> where
S: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Create a new Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more
type Output = T
type Output = T
Should always be Self