From 79f6ebdc099496401554aee8a2b9cb7540389422 Mon Sep 17 00:00:00 2001 From: KD Date: Thu, 3 Apr 2025 12:25:01 -0400 Subject: [PATCH] Moved router code to its own function --- src/main.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 80e37ee..3e254b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,11 +21,7 @@ async fn main() { axum::serve(listener, app).await.unwrap(); } -async fn app() -> Router { - let pool = icarus_auth::db_pool::create_pool() - .await - .expect("Failed to create pool"); - +async fn routes() -> Router { // build our application with a route Router::new() .route(callers::endpoints::DBTEST, get(callers::common::db_ping)) @@ -34,7 +30,14 @@ async fn app() -> Router { callers::endpoints::REGISTER, post(callers::register::register_user), ) - .layer(axum::Extension(pool)) +} + +async fn app() -> Router { + let pool = icarus_auth::db_pool::create_pool() + .await + .expect("Failed to create pool"); + + routes().await.layer(axum::Extension(pool)) } #[cfg(test)]