diff --git a/src/main.rs b/src/main.rs index 6dcac7f..51d9e20 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,8 +57,6 @@ impl Args { } } -static mut ARGS: Option = None; - struct NewFile { path: PathBuf, bytes: Vec, @@ -219,8 +217,6 @@ async fn main() -> std::io::Result<()> { panic!("Specified files path does not exists!"); } - unsafe { ARGS = Some(args.clone()); } - HttpServer::new(move || { App::new() @@ -238,7 +234,8 @@ async fn main() -> std::io::Result<()> { .default_handler(fn_service(|req: ServiceRequest| async { let (req, _) = req.into_parts(); - if let Some(h) = unsafe { ARGS.as_ref().unwrap() }.default_handler_path().as_ref() { + let args: &web::Data = req.app_data().unwrap(); + if let Some(h) = args.default_handler_path() { let file = NamedFile::open_async(h).await?; let res = file.into_response(&req); Ok(ServiceResponse::new(req, res))