From 15c1f4d38d4cc44cb16cb5a1dca26aa92457ac23 Mon Sep 17 00:00:00 2001 From: ozpv <39195175+ozpv@users.noreply.github.com> Date: Sat, 30 May 2026 15:12:28 -0500 Subject: inject update --- src/main.rs | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/src/main.rs b/src/main.rs index f39c843..fe5b798 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,30 +59,22 @@ async fn inject( async fn get_file(State(state): State, mut req: Request) -> impl IntoResponse { if req.uri().path() == "/" { *req.uri_mut() = "/index.html".parse().map_err(|_| ERR)?; - - return ServeDir::new(state.get_dist_dir().as_ref()) - .precompressed_br() - .precompressed_gzip() - .fallback(not_found.into_service()) - .oneshot(req) - .await - .map_err(|_| ERR); + } else { + let mut file_path = PathBuf::from(req.uri().path()); + + if file_path.extension().is_none() { + file_path.set_extension("html"); + } + + *req.uri_mut() = file_path + .to_str() + // in case this were to run on a windows machine + .map(|s| s.replace('\\', "/")) + .ok_or(ERR)? + .parse() + .map_err(|_| ERR)?; } - let mut file_path = PathBuf::from(req.uri().path()); - - if file_path.extension().is_none() { - file_path.set_extension("html"); - } - - *req.uri_mut() = file_path - .to_str() - // in case this were to run on a windows machine - .map(|s| s.replace('\\', "/")) - .ok_or(ERR)? - .parse() - .map_err(|_| ERR)?; - ServeDir::new(state.get_dist_dir().as_ref()) .precompressed_br() .precompressed_gzip() -- cgit v1.2.3