feat: add middleware
This commit is contained in:
+5
-4
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user