diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -9,10 +9,10 @@ pub mod error; pub mod state; pub mod utils; -pub fn router(state: state::AppState) -> axum::Router { +pub fn router() -> axum::Router<state::AppState> { axum::Router::new() - .nest("/api", api::router(state.clone())) - .nest("/auth", auth::router(state.clone())) + .nest("/api", api::router()) + .merge(auth::router()) .fallback(fallback) // TODO: do this correctly! .layer(CorsLayer::permissive()) @@ -34,6 +34,7 @@ pub(crate) mod tests { use axum::{ body::Body, http::{Request, StatusCode}, + Router, }; use sqlx::PgPool; use tower::ServiceExt; @@ -60,7 +61,7 @@ pub(crate) mod tests { async fn test_fallback_not_found(pool: PgPool) -> TestResult { setup_test_env(); - let router = router(AppState { pool }); + let router = Router::new().merge(router()).with_state(AppState { pool }); let request = Request::builder() .uri("/does-not-exist") |