From b404344a7c4ab5cb6c7d7b445fab796be79b848f Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Tue, 3 Sep 2024 01:25:20 -0400 Subject: Allow login creation and authentication. This is a beefy change, as it adds a TON of smaller pieces needed to make this all function: * A database migration. * A ton of new crates for things like password validation, timekeeping, and HTML generation. * A first cut at a module structure for routes, templates, repositories. * A family of ID types, for identifying various kinds of domain thing. * AppError, which _doesn't_ implement Error but can be sent to clients. --- src/cli.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/cli.rs') diff --git a/src/cli.rs b/src/cli.rs index 0880020..191e331 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,12 +1,14 @@ use std::io; use std::str::FromStr; -use axum::{routing::get, Router}; +use axum::Router; use clap::Parser; use sqlx::sqlite::{SqliteConnectOptions, SqlitePool, SqlitePoolOptions}; use tokio::net; -pub type Result = std::result::Result>; +use crate::{error::BoxedError, index, login}; + +pub type Result = std::result::Result; #[derive(Parser)] pub struct Args { @@ -26,7 +28,7 @@ impl Args { sqlx::migrate!().run(&pool).await?; - let app = Router::new().route("/", get(hello)).with_state(pool); + let app = routers().with_state(pool); let listener = self.listener().await?; let started_msg = started_msg(&listener)?; @@ -58,11 +60,11 @@ impl Args { } } +fn routers() -> Router { + index::router().merge(login::router()) +} + fn started_msg(listener: &net::TcpListener) -> io::Result { let local_addr = listener.local_addr()?; Ok(format!("listening on http://{local_addr}/")) } - -async fn hello() -> &'static str { - "Hello, world" -} -- cgit v1.2.3