Skip to main content

fallback

Macro fallback 

Source
macro_rules! fallback {
    ($handler:expr) => { ... };
}
Expand description

Create a fallback route definition

The fallback handler is called when no other routes match the request, allowing you to override the default 404 behavior.

§Example

routes! {
    get!("/", controllers::home::index),
    get!("/users", controllers::user::index),

    // Custom 404 handler
    fallback!(controllers::fallback::invoke),
}

With middleware:

routes! {
    get!("/", controllers::home::index),
    fallback!(controllers::fallback::invoke).middleware(LoggingMiddleware),
}