From f2f820370efbd5c6d0f304f781284a9f68990e21 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Wed, 11 Sep 2024 22:43:14 -0400 Subject: Wrap the database pool in an App struct. This is a jumping-off point for adding logic that needs more than just the DB for state, such as chat message handling. The name sucks, but it's the best I've got. --- src/cli.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/cli.rs') diff --git a/src/cli.rs b/src/cli.rs index eef006e..6b24b65 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -6,7 +6,7 @@ use clap::Parser; use sqlx::sqlite::{SqliteConnectOptions, SqlitePool, SqlitePoolOptions}; use tokio::net; -use crate::{channel, clock, error::BoxedError, index, login}; +use crate::{app::App, channel, clock, error::BoxedError, index, login}; pub type Result = std::result::Result; @@ -30,7 +30,7 @@ impl Args { let app = routers() .route_layer(middleware::from_fn(clock::middleware)) - .with_state(pool); + .with_state(App::from(pool)); let listener = self.listener().await?; let started_msg = started_msg(&listener)?; @@ -62,7 +62,7 @@ impl Args { } } -fn routers() -> Router { +fn routers() -> Router { [channel::router(), login::router()] .into_iter() .fold(index::router(), Router::merge) -- cgit v1.2.3