Struct pavex::blueprint::router::RegisteredRoute
source · pub struct RegisteredRoute<'a> { /* private fields */ }
Expand description
The type returned by Blueprint::route
.
It allows you to further configure the behaviour of the registered route.
Implementations§
source§impl<'a> RegisteredRoute<'a>
impl<'a> RegisteredRoute<'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 route, 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;
use pavex::blueprint::{Blueprint, router::GET};
use pavex::response::Response;
// 👇 a fallible request handler
fn request_handler() -> Result<Response, RuntimeError> {
// [...]
}
fn error_to_response(error: &ConfigurationError, log_level: LogLevel) -> Response {
// [...]
}
let mut bp = Blueprint::new();
bp.route(GET, "/home", f!(crate::request_handler))
.error_handler(f!(crate::error_to_response));
Auto Trait Implementations§
impl<'a> Freeze for RegisteredRoute<'a>
impl<'a> RefUnwindSafe for RegisteredRoute<'a>
impl<'a> Send for RegisteredRoute<'a>
impl<'a> Sync for RegisteredRoute<'a>
impl<'a> Unpin for RegisteredRoute<'a>
impl<'a> !UnwindSafe for RegisteredRoute<'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