feat(axum): expose hashed runtime asset path

Generate a SHA-256 content hash for the embedded hemx runtime, expose the hashed path from hemx-axum, serve immutable runtime headers, and update examples to load the hemx-owned path instead of fixed /hemx.js URLs.

req: axum_integration/005
This commit is contained in:
slhx agent
2026-06-05 18:25:14 +02:00
parent c56ec39813
commit ce4c2e086d
20 changed files with 204 additions and 36 deletions
+8 -4
View File
@@ -6,8 +6,8 @@ use futures_util::{stream, StreamExt};
use hemplate::Hemplate;
use hemx::{Html, IntoEffect};
use hemx_axum::{
interactions, runtime_js, sse, EffectResponse, Form, HandlerErrorContext, HandlerFailure,
InteractionRequest, IntoHandlerFailure, PageRequest, Registry,
interactions, runtime_js, runtime_js_path, sse, EffectResponse, Form, HandlerErrorContext,
HandlerFailure, InteractionRequest, IntoHandlerFailure, PageRequest, Registry,
};
use hemx_v0_examples::ui;
use hemx_v0_examples::ui::{auth, counter, notifications, page_swap, todo_row, todos, wizard};
@@ -178,6 +178,7 @@ struct PageSwap {
#[derive(Hemplate)]
struct AppShell {
runtime_src: &'static str,
body: Html,
}
@@ -194,7 +195,7 @@ async fn main() {
.route("/", get(home).post(interact))
.route("/docs", get(docs).post(interact))
.route("/events", get(events))
.route("/hemx.js", get(runtime))
.route(runtime_js_path(), get(runtime))
.with_state(state);
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
@@ -278,7 +279,10 @@ fn all_examples() -> Html {
fn shell(body: Html) -> Html {
// req: html_safety/001 req: html_safety/002 req: axum_integration/001 req: component/003
hemx::page(&AppShell { body })
hemx::page(&AppShell {
runtime_src: runtime_js_path(),
body,
})
}
#[hemx::component("counter")]