diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 36 |
1 files 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<AppState>, 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() |
