diff --git a/kitchen/src/web.rs b/kitchen/src/web.rs index 1c12fd9..f49e076 100644 --- a/kitchen/src/web.rs +++ b/kitchen/src/web.rs @@ -73,14 +73,23 @@ where async fn ui_assets(Path(path): Path) -> impl IntoResponse { info!("Serving ui path"); - let mut path = path.trim_start_matches("/"); - path = if path == "" { "index.html" } else { path }; + let path = path.trim_start_matches("/"); debug!(path = path, "Serving transformed path"); let file = StaticFile(path.to_owned()); + // TODO(jwall): We need to construct the entire html page here. + // not just this split form. if file.exists() { file.into_response() } else { - kitchen_wasm::render_to_string(path).into_response() + let index = UiAssets::get("index.html").expect("Unexpectedly can't find index.html"); + let body = boxed(Full::from( + String::from_utf8_lossy(index.data.as_ref()) + .replace("%kitchen-wasm", &kitchen_wasm::render_to_string(path)), + )); + Response::builder() + .header(header::CONTENT_TYPE, "text/html") + .body(body) + .unwrap() } } diff --git a/web/index.html b/web/index.html index 4d1bbee..211b874 100644 --- a/web/index.html +++ b/web/index.html @@ -24,7 +24,7 @@ -
+
%kitchen-wasm