diff --git a/Cargo.lock b/Cargo.lock index 7a0f572..9227e9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1035,7 +1035,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] -name = "morethantext_web" +name = "morethantext" version = "0.1.0" dependencies = [ "async-std", diff --git a/Cargo.toml b/Cargo.toml index eecb8aa..bf26dfd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "morethantext_web" +name = "morethantext" version = "0.1.0" edition = "2021" diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..a9769d7 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,8 @@ +#[derive(Clone)] +pub struct Database {} + +impl Database { + pub fn new() -> Self { + Self {} + } +} diff --git a/src/main.rs b/src/main.rs index b3eaf6e..246e4ee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use morethantext::Database; use tide::{ http::StatusCode, sessions::{MemoryStore, SessionMiddleware}, @@ -17,8 +18,9 @@ async fn main() -> tide::Result<()> { Ok(()) } -async fn app_setup() -> tide::Server<()> { - let mut app = tide::new(); +async fn app_setup() -> tide::Server { + let db = Database::new(); + let mut app = tide::with_state(db); app.at("/").get(home); app.with( SessionMiddleware::new(MemoryStore::new(), b"361f953f-56ba-45e6-86ab-9efbf61b745d") @@ -27,7 +29,7 @@ async fn app_setup() -> tide::Server<()> { return app; } -async fn home(_req: Request<()>) -> tide::Result { +async fn home(_req: Request) -> tide::Result { let mut res = Response::new(StatusCode::Ok); res.set_body("