From 40b6625620b17574b1af9f0e3d35c5e7f7eb023b Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Thu, 27 Oct 2022 19:27:39 -0400 Subject: [PATCH] Better Static Asset serving and fix extra header --- kitchen/src/web/mod.rs | 20 +++++++++++--------- web/src/web.rs | 1 - 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/kitchen/src/web/mod.rs b/kitchen/src/web/mod.rs index 5cd3aab..a1b8fdc 100644 --- a/kitchen/src/web/mod.rs +++ b/kitchen/src/web/mod.rs @@ -69,16 +69,18 @@ async fn ui_static_assets(Path(path): Path) -> impl IntoResponse { info!("Serving ui path"); let mut path = path.trim_start_matches("/"); - path = match path { - "" | "inventory" | "plan" | "cook" | "categories" | "login" => "index.html", - _ => { - if path.starts_with("recipe") { - "index.html" - } else { - path + if UiAssets::get(path).is_none() { + path = match path { + "" | "inventory" | "plan" | "cook" | "categories" | "login" => "index.html", + _ => { + if path.starts_with("recipe") { + "index.html" + } else { + path + } } - } - }; + }; + } debug!(path = path, "Serving transformed path"); StaticFile(path.to_owned()) } diff --git a/web/src/web.rs b/web/src/web.rs index 1751d8d..773969c 100644 --- a/web/src/web.rs +++ b/web/src/web.rs @@ -67,7 +67,6 @@ pub fn UI(cx: Scope) -> View { }; view.set(view! { cx, div(class="app") { - Header() Router(RouterProps { route: Routes::Plan, route_select: route_switch,