diff options
author | tcmal <me@aria.rip> | 2024-09-08 18:46:43 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-09-12 16:30:09 +0100 |
commit | 9a7042df7f9a7ad0324c4442ae918c2a4a442966 (patch) | |
tree | 81324f03df3ddaac9db7d1e01ef5b319bef659ef /crates/web | |
parent | ddc97e9361137fde6f0894ffa729d285159662fa (diff) |
Add framework for separate printer control thread
Diffstat (limited to 'crates/web')
-rw-r--r-- | crates/web/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/web/src/main.rs | 20 |
2 files changed, 14 insertions, 7 deletions
diff --git a/crates/web/Cargo.toml b/crates/web/Cargo.toml index 62a3504..2528a0a 100644 --- a/crates/web/Cargo.toml +++ b/crates/web/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] +argonaut-control = { path = "../control" } axum = "0.7.5" tracing = { workspace = true } tracing-subscriber = { workspace = true } diff --git a/crates/web/src/main.rs b/crates/web/src/main.rs index f641ce0..d80b232 100644 --- a/crates/web/src/main.rs +++ b/crates/web/src/main.rs @@ -1,17 +1,23 @@ -use axum::{ - http::StatusCode, - routing::{get, post}, - Json, Router, -}; -use serde::{Deserialize, Serialize}; +use std::sync::Arc; + +use axum::{routing::get, Router}; + +pub use argonaut_control::Handle as PrinterThread; +use tracing::info; #[tokio::main(flavor = "current_thread")] async fn main() { tracing_subscriber::fmt::init(); - let app = Router::new().route("/", get(root)); + let printer_thread = PrinterThread::spawn(); + let printer_thread = Arc::new(printer_thread); + let app = Router::new() + .route("/", get(root)) + .with_state(printer_thread); let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); + + info!("init completed, listening"); axum::serve(listener, app).await.unwrap(); } |