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
+5 -1
View File
@@ -4,7 +4,8 @@ pub mod ui {}
use hemplate::Hemplate;
use hemx::{push, Html, IntoEffect};
use hemx_axum::{
interactions, Form, HandlerErrorContext, HandlerFailure, IntoHandlerFailure, Registry, State,
interactions, runtime_js_path, Form, HandlerErrorContext, HandlerFailure, IntoHandlerFailure,
Registry, State,
};
use std::convert::Infallible;
use std::fmt::Display;
@@ -248,12 +249,14 @@ impl SettingsPage {
#[derive(Hemplate)]
pub struct AppShell {
title: &'static str,
runtime_src: &'static str,
body: Html,
}
pub fn home_page(ctx: &AppContext) -> Html {
hemx::page(&AppShell {
title: "hemx SaaS tutorial",
runtime_src: runtime_js_path(),
body: hemx::page(&Dashboard::from_context(ctx)),
})
}
@@ -261,6 +264,7 @@ pub fn home_page(ctx: &AppContext) -> Html {
pub fn settings_page(ctx: &AppContext) -> Html {
hemx::page(&AppShell {
title: "hemx SaaS tutorial settings",
runtime_src: runtime_js_path(),
body: hemx::page(&Dashboard::settings(ctx)),
})
}
+2 -2
View File
@@ -5,7 +5,7 @@ use axum::routing::get;
use axum::Router;
use futures_util::stream;
use hemx::IntoEffect;
use hemx_axum::{runtime_js, sse, EffectResponse, InteractionRequest};
use hemx_axum::{runtime_js, runtime_js_path, sse, EffectResponse, InteractionRequest};
use hemx_saas_example::{home_page, live_status, registry, settings_page, ui, AppContext};
use std::collections::BTreeMap;
use std::convert::Infallible;
@@ -26,7 +26,7 @@ fn app(ctx: AppContext) -> Router {
.route("/", get(home).post(interact))
.route("/settings", get(settings))
.route("/events", get(events))
.route("/hemx.js", get(runtime))
.route(runtime_js_path(), get(runtime))
.route("/app.css", get(css))
.route("/metrics.js", get(metrics_js))
.with_state(ctx)