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:
@@ -5,9 +5,9 @@ pub mod ui {}
|
||||
mod tests {
|
||||
use super::ui::{board, board_card};
|
||||
use hemplate::Hemplate;
|
||||
use scraper::{Html, Selector};
|
||||
use hemx::IntoEffect;
|
||||
use hemx_test::inspect;
|
||||
use scraper::{Html, Selector};
|
||||
|
||||
#[derive(Hemplate)]
|
||||
#[hemplate = "partials"]
|
||||
|
||||
@@ -6,8 +6,8 @@ use futures_util::{stream, StreamExt};
|
||||
use hemplate::Hemplate;
|
||||
use hemx::{Html, IntoEffect};
|
||||
use hemx_axum::{
|
||||
interactions, runtime_js, sse, DispatchRegistry, DispatchRejection, EffectResponse,
|
||||
InteractionRequest, PageRequest,
|
||||
interactions, runtime_js, runtime_js_path, sse, DispatchRegistry, DispatchRejection,
|
||||
EffectResponse, InteractionRequest, PageRequest,
|
||||
};
|
||||
use hemx_kanban_example::ui::board::{self as board};
|
||||
use hemx_kanban_example::ui::board_card as card_board;
|
||||
@@ -40,6 +40,7 @@ struct Card {
|
||||
|
||||
#[derive(Hemplate)]
|
||||
struct AppShell {
|
||||
runtime_src: &'static str,
|
||||
body: Html,
|
||||
}
|
||||
|
||||
@@ -118,7 +119,7 @@ async fn main() {
|
||||
let app = Router::new()
|
||||
.route("/", get(home).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], 3001));
|
||||
@@ -288,7 +289,10 @@ fn page_html(board: &BoardState) -> Html {
|
||||
|
||||
fn shell(body: Html) -> Html {
|
||||
// req: html_safety/001 req: html_safety/002 req: axum_integration/001
|
||||
hemx::page(&AppShell { body })
|
||||
hemx::page(&AppShell {
|
||||
runtime_src: runtime_js_path(),
|
||||
body,
|
||||
})
|
||||
}
|
||||
|
||||
fn render_options() -> Html {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>hemx Kanban</title>
|
||||
<script src="/hemx.js" defer></script>
|
||||
<script +src="self.runtime_src" defer></script>
|
||||
<style>
|
||||
body { font-family: system-ui, sans-serif; margin: 2rem; }
|
||||
form { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
|
||||
|
||||
Reference in New Issue
Block a user