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
+21
View File
@@ -0,0 +1,21 @@
use sha2::{Digest, Sha256};
use std::env;
use std::fs;
use std::path::Path;
fn main() {
let runtime_path = Path::new("runtime/hemx.js");
println!("cargo:rerun-if-changed={}", runtime_path.display());
let runtime = fs::read(runtime_path).expect("read hemx runtime");
let hash = format!("{:x}", Sha256::digest(&runtime));
let out_dir = env::var("OUT_DIR").expect("OUT_DIR");
fs::write(
Path::new(&out_dir).join("runtime_asset.rs"),
format!(
"pub const RUNTIME_JS_HASH: &str = \"{hash}\";\n\
pub const RUNTIME_JS_PATH: &str = \"/hemx.{hash}.js\";\n"
),
)
.expect("write runtime asset constants");
}