Struct pavex::blueprint::middleware::RegisteredWrappingMiddleware
source · pub struct RegisteredWrappingMiddleware<'a> { /* private fields */ }
Expand description
The type returned by Blueprint::wrap
.
It allows you to further configure the behaviour of the registered wrapping middleware.
Implementations§
source§impl<'a> RegisteredWrappingMiddleware<'a>
impl<'a> RegisteredWrappingMiddleware<'a>
sourcepub fn error_handler(self, error_handler: RawIdentifiers) -> Self
pub fn error_handler(self, error_handler: RawIdentifiers) -> Self
Register an error handler.
If an error handler has already been registered for this middleware, it will be overwritten.
§Guide
Check out the “Error handlers” section of Pavex’s guide for a thorough introduction to error handlers in Pavex applications.
§Example
use pavex::{f, blueprint::Blueprint, middleware::Next};
use pavex::response::Response;
use std::future::Future;
// 👇 a fallible middleware
fn timeout_middleware<C>(next: Next<C>) -> Result<Response, TimeoutError>
where
C: Future<Output = Response>
{
// [...]
}
fn error_to_response(error: &TimeoutError, log_level: LogLevel) -> Response {
// [...]
}
let mut bp = Blueprint::new();
bp.wrap(f!(crate::timeout_middleware))
.error_handler(f!(crate::error_to_response));
Auto Trait Implementations§
impl<'a> Freeze for RegisteredWrappingMiddleware<'a>
impl<'a> RefUnwindSafe for RegisteredWrappingMiddleware<'a>
impl<'a> Send for RegisteredWrappingMiddleware<'a>
impl<'a> Sync for RegisteredWrappingMiddleware<'a>
impl<'a> Unpin for RegisteredWrappingMiddleware<'a>
impl<'a> !UnwindSafe for RegisteredWrappingMiddleware<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more