Better Static Asset serving and fix extra header

This commit is contained in:
Jeremy Wall 2022-10-27 19:27:39 -04:00
parent 5f4b7c3f02
commit 40b6625620
2 changed files with 11 additions and 10 deletions

View File

@ -69,6 +69,7 @@ async fn ui_static_assets(Path(path): Path<String>) -> impl IntoResponse {
info!("Serving ui path"); info!("Serving ui path");
let mut path = path.trim_start_matches("/"); let mut path = path.trim_start_matches("/");
if UiAssets::get(path).is_none() {
path = match path { path = match path {
"" | "inventory" | "plan" | "cook" | "categories" | "login" => "index.html", "" | "inventory" | "plan" | "cook" | "categories" | "login" => "index.html",
_ => { _ => {
@ -79,6 +80,7 @@ async fn ui_static_assets(Path(path): Path<String>) -> impl IntoResponse {
} }
} }
}; };
}
debug!(path = path, "Serving transformed path"); debug!(path = path, "Serving transformed path");
StaticFile(path.to_owned()) StaticFile(path.to_owned())
} }

View File

@ -67,7 +67,6 @@ pub fn UI<G: Html>(cx: Scope) -> View<G> {
}; };
view.set(view! { cx, view.set(view! { cx,
div(class="app") { div(class="app") {
Header()
Router(RouterProps { Router(RouterProps {
route: Routes::Plan, route: Routes::Plan,
route_select: route_switch, route_select: route_switch,