Remove useless unsafe code
This commit is contained in:
parent
673001ed36
commit
8fd0981e78
@ -57,8 +57,6 @@ impl Args {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static mut ARGS: Option<Args> = None;
|
|
||||||
|
|
||||||
struct NewFile {
|
struct NewFile {
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
bytes: Vec<u8>,
|
bytes: Vec<u8>,
|
||||||
@ -219,8 +217,6 @@ async fn main() -> std::io::Result<()> {
|
|||||||
panic!("Specified files path does not exists!");
|
panic!("Specified files path does not exists!");
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe { ARGS = Some(args.clone()); }
|
|
||||||
|
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
App::new()
|
App::new()
|
||||||
|
|
||||||
@ -238,7 +234,8 @@ async fn main() -> std::io::Result<()> {
|
|||||||
|
|
||||||
.default_handler(fn_service(|req: ServiceRequest| async {
|
.default_handler(fn_service(|req: ServiceRequest| async {
|
||||||
let (req, _) = req.into_parts();
|
let (req, _) = req.into_parts();
|
||||||
if let Some(h) = unsafe { ARGS.as_ref().unwrap() }.default_handler_path().as_ref() {
|
let args: &web::Data<Args> = req.app_data().unwrap();
|
||||||
|
if let Some(h) = args.default_handler_path() {
|
||||||
let file = NamedFile::open_async(h).await?;
|
let file = NamedFile::open_async(h).await?;
|
||||||
let res = file.into_response(&req);
|
let res = file.into_response(&req);
|
||||||
Ok(ServiceResponse::new(req, res))
|
Ok(ServiceResponse::new(req, res))
|
||||||
|
Loading…
Reference in New Issue
Block a user