diff --git a/src/backend/assets.rs b/src/backend/assets.rs index c38f913..3bda404 100644 --- a/src/backend/assets.rs +++ b/src/backend/assets.rs @@ -1,4 +1,3 @@ -use crate::frontend::app::App; use axum::{ body::Body, extract::{Request, State}, @@ -16,9 +15,9 @@ use tower_http::services::ServeDir; pub async fn file_and_error_handler( State(options): State, req: Request, -) -> Result, (StatusCode, String)> { +) -> Result, StatusCode> { let root = options.site_root.clone(); - let (parts, body) = req.into_parts(); + let (parts, _) = req.into_parts(); let mut static_parts = parts.clone(); static_parts.headers.clear(); @@ -33,29 +32,17 @@ pub async fn file_and_error_handler( if res.status() == StatusCode::OK { Ok(res.into_response()) } else { - let handler = leptos_axum::render_app_to_stream(options.to_owned(), App); - Ok(handler(Request::from_parts(parts, body)) - .await - .into_response()) + Err(StatusCode::NOT_FOUND) } } -async fn get_static_file( - request: Request, - root: &str, -) -> Result, (StatusCode, String)> { +async fn get_static_file(request: Request, root: &str) -> Result, StatusCode> { // `ServeDir` implements `tower::Service` so we can call it with `tower::ServiceExt::oneshot` // This path is relative to the cargo root - match ServeDir::new(root) + Ok(ServeDir::new(root) .precompressed_gzip() .precompressed_br() .oneshot(request) .await - { - Ok(res) => Ok(res.into_response()), - Err(err) => Err(( - StatusCode::INTERNAL_SERVER_ERROR, - format!("Error serving files: {err}"), - )), - } + .into_response()) }