diff --git a/examples/hackernews_axum/src/file.rs b/examples/hackernews_axum/src/file.rs index deca643fb..ed740a229 100644 --- a/examples/hackernews_axum/src/file.rs +++ b/examples/hackernews_axum/src/file.rs @@ -9,16 +9,12 @@ if #[cfg(feature = "ssr")] { }; use tower::ServiceExt; use tower_http::services::ServeDir; - use std::str::FromStr; use std::sync::Arc; use leptos::LeptosOptions; pub async fn file_handler(uri: Uri, Extension(options): Extension>) -> Result, (StatusCode, String)> { let options = &*options; - // URIs need the leading slash - // let full_path = format!("/{file_path}"); - // let uri = Uri::from_str(&full_path).unwrap(); let root = options.site_root.clone(); let res = get_static_file(uri.clone(), &root).await?; diff --git a/examples/todo_app_sqlite_axum/src/file.rs b/examples/todo_app_sqlite_axum/src/file.rs index ceb3c8ed0..ed740a229 100644 --- a/examples/todo_app_sqlite_axum/src/file.rs +++ b/examples/todo_app_sqlite_axum/src/file.rs @@ -9,16 +9,12 @@ if #[cfg(feature = "ssr")] { }; use tower::ServiceExt; use tower_http::services::ServeDir; - use std::str::FromStr; use std::sync::Arc; use leptos::LeptosOptions; - pub async fn file_handler(Path(file_path): Path, Extension(options): Extension>) -> Result, (StatusCode, String)> { + pub async fn file_handler(uri: Uri, Extension(options): Extension>) -> Result, (StatusCode, String)> { let options = &*options; - // URIs need the leading slash - let full_path = format!("/{file_path}"); - let uri = Uri::from_str(&full_path).unwrap(); let root = options.site_root.clone(); let res = get_static_file(uri.clone(), &root).await?; diff --git a/examples/todo_app_sqlite_axum/src/main.rs b/examples/todo_app_sqlite_axum/src/main.rs index 81e80b5b6..859da45c7 100644 --- a/examples/todo_app_sqlite_axum/src/main.rs +++ b/examples/todo_app_sqlite_axum/src/main.rs @@ -35,7 +35,7 @@ if #[cfg(feature = "ssr")] { let app = Router::new() .route("/api/*fn_name", post(leptos_axum::handle_server_fns)) .leptos_routes(leptos_options.clone(), routes, |cx| view! { cx, } ) - .route("/*file_path", get(file_handler)) + .fallback(file_handler) .layer(Extension(Arc::new(leptos_options))); // run our app with hyper