ayun-server 0.23.0

The RUST Framework for Web Rustceans.
Documentation
use crate::{traits::MiddlewareTrait, Middleware};
use axum::{http::StatusCode, response::IntoResponse};

pub struct Fallback;

impl MiddlewareTrait for Fallback {
    fn handle() -> Middleware {
        Box::new(|router| {
            Ok(router.fallback(|| async {
                #[cfg(not(feature = "response-json"))]
                {
                    StatusCode::NOT_FOUND.into_response()
                }

                #[cfg(feature = "response-json")]
                {
                    crate::response::json()
                        .code(StatusCode::NOT_FOUND)
                        .into_response()
                }
            }))
        })
    }
}