diff --git a/src/main.rs b/src/main.rs index 8d41f8c..013e7af 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,9 +16,8 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::process; use std::sync::Arc; use tracing::info; -use tracing_appender::non_blocking::WorkerGuard; -async fn init() -> Result { +async fn init() -> Result<()> { let mut config = config::Config::new()?; let path_prefix = config.path_prefix.clone(); let mailer = Arc::new(mailer::Mailer::new(&mut config)?); @@ -31,7 +30,7 @@ async fn init() -> Result { config.socket_address.port, ); - let tracing_worker_gurad = logging::init_logger(&config.logging); + let _tracing_gurad = logging::init_logger(&config.logging); let config = Arc::new(config); let captcha_solutions = Arc::new(captcha_solutions::SharedCaptchaSolutions::default()); @@ -42,14 +41,14 @@ async fn init() -> Result { captcha_solutions, }; - let spa = SpaRouter::new(&format!("{}/static", &path_prefix), "static"); - let routes = Router::new() .route("/", get(routes::index)) .route("/", post(routes::submit)) .route("/success", get(routes::success)) .with_state(app_state); + let spa = SpaRouter::new(&format!("{}/static", &path_prefix), "static"); + let app = Router::new().nest(&path_prefix, routes).merge(spa); info!("Starting server"); @@ -58,12 +57,12 @@ async fn init() -> Result { .await .unwrap(); - Ok(tracing_worker_gurad) + Ok(()) } #[tokio::main] async fn main() { - let _tracing_worker_gurad = init().await.unwrap_or_else(|e| { + init().await.unwrap_or_else(|e| { eprintln!("{e:?}"); process::exit(1); });