pub struct RegisteredPreProcessingMiddleware<'a> { /* private fields */ }
Expand description
The type returned by Blueprint::pre_process
.
It allows you to further configure the behaviour of the registered pre-processing middleware.
Implementations§
source§impl<'a> RegisteredPreProcessingMiddleware<'a>
impl<'a> RegisteredPreProcessingMiddleware<'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::Processing};
use pavex::request::RequestHead;
use pavex::response::Response;
// 👇 a fallible middleware
fn reject_anonymous(request_head: &RequestHead) -> Result<Processing, AuthError>
{
// [...]
}
fn error_to_response(error: &AuthError, log_level: LogLevel) -> Response {
// [...]
}
let mut bp = Blueprint::new();
bp.wrap(f!(crate::reject_anonymous))
.error_handler(f!(crate::error_to_response));
Auto Trait Implementations§
impl<'a> Freeze for RegisteredPreProcessingMiddleware<'a>
impl<'a> RefUnwindSafe for RegisteredPreProcessingMiddleware<'a>
impl<'a> Send for RegisteredPreProcessingMiddleware<'a>
impl<'a> Sync for RegisteredPreProcessingMiddleware<'a>
impl<'a> Unpin for RegisteredPreProcessingMiddleware<'a>
impl<'a> !UnwindSafe for RegisteredPreProcessingMiddleware<'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