feat: add middleware

This commit is contained in:
Maulana Sodiqin
2025-03-15 01:53:20 +07:00
parent 7ab036f5f7
commit b096f4129a
6 changed files with 77 additions and 25 deletions
+5 -4
View File
@@ -1,5 +1,4 @@
use axum::Router;
use axum::{middleware::from_fn, Router};
pub mod auth;
pub mod docs;
pub mod gacha;
@@ -11,7 +10,9 @@ pub use gacha::*;
pub use users::*;
pub async fn routes() -> Router {
Router::new()
.nest("/auth", auth_router())
let public_routes = Router::new().nest("/auth", auth_router());
let protected_routes = Router::new()
.nest("/gacha", gacha_router())
.layer(from_fn(auth::auth_middleware::auth_middleware));
Router::new().merge(public_routes).merge(protected_routes)
}