Implement basic middleware handling
All checks were successful
Test / verify-generated-code (pull_request) Successful in 8m1s
Test / test (pull_request) Successful in 1m9s
Test / lint (pull_request) Successful in 1m5s

This commit is contained in:
GW_MC
2025-12-02 15:47:56 +08:00
parent 547d73fab7
commit 6cd55d06a2
5 changed files with 45 additions and 22 deletions

View File

@@ -1,8 +1,11 @@
use std::sync::Arc;
use axum::Router;
use axum::{Extension, Router};
use migration::sea_orm::DatabaseConnection;
use crate::middlewares;
#[derive(Clone)]
pub struct AppState {
// TODO: remove dead_code allowances when fields are used
#[allow(dead_code)]
@@ -17,11 +20,12 @@ pub struct AppService {
}
pub fn get_root_router(state: impl Into<Arc<AppState>>) -> Router {
let router = Router::new()
// TODO: Add routes
.with_state(state.into());
let mut router = Router::new();
router = middlewares::apply_root_middleware(router);
router = router.layer(Extension(state.into()));
#[allow(clippy::let_and_return)]
router
}