diff options
Diffstat (limited to 'src/index.rs')
| -rw-r--r-- | src/index.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/index.rs b/src/index.rs index 9efd7cc..843cb77 100644 --- a/src/index.rs +++ b/src/index.rs @@ -1,28 +1,26 @@ use axum::{extract::State, routing::get, Router}; use maud::Markup; -use sqlx::sqlite::SqlitePool; -use crate::{channel::repo::Provider as _, error::InternalError, login::repo::logins::Login}; +use crate::{ + app::App, channel::repo::Provider as _, error::InternalError, login::repo::logins::Login, +}; -async fn index( - State(db): State<SqlitePool>, - login: Option<Login>, -) -> Result<Markup, InternalError> { +async fn index(State(app): State<App>, login: Option<Login>) -> Result<Markup, InternalError> { match login { None => Ok(templates::unauthenticated()), - Some(login) => index_authenticated(db, login).await, + Some(login) => index_authenticated(app, login).await, } } -async fn index_authenticated(db: SqlitePool, login: Login) -> Result<Markup, InternalError> { - let mut tx = db.begin().await?; +async fn index_authenticated(app: App, login: Login) -> Result<Markup, InternalError> { + let mut tx = app.db.begin().await?; let channels = tx.channels().all().await?; tx.commit().await?; Ok(templates::authenticated(login, &channels)) } -pub fn router() -> Router<SqlitePool> { +pub fn router() -> Router<App> { Router::new().route("/", get(index)) } |
