summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 8be6698..2afed5e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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")