Upgrade leptos_ssr_axum example to latest leptos_wasi and WASIp3#3
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR updates the
leptos_ssr_axumexample inexamples/leptos_ssr_axumto align with the latestleptos_wasichanges, switching to the WASIp3 http trigger standard.Changes Made
1. Updated
Cargo.tomledition = "2024"andrust-version = "1.93.0".build = "build.rs".bytes,futures,hydration_context,server_fn,wasip3,http, andhttp-body.leptos_wasito point to the official repository at revision216acc484b0d6fe4b18876f1c96b68272498592b.spin-sdkto version6.0.0withjsonfeature.wasm-releaseprofiles and targets (wasm32-wasip2).2. Configured
spin.tomlexecutor = { type = "http" }for trigger.target/wasm32-wasip2/release/leptos_ssr_axum.wasminstead ofwasm32-wasip1.WASI_RUNTIME=spin.3. Added
build.rsWASI_RUNTIMEenvironment variable into standardruntime_spin/runtime_wasmtimecompiler flags.4. Code Migration & Refactoring
src/server.rs:Guestimplementation to the latestwasip3::exports::http::handler::Guestpattern.init_wasip3_spawner().Requesttohttp::Requestusingwasip3::http_compat::http_from_wasi_request.Handlerbuilt natively usingHandler::build(req).awaitand bound server functions.serve_static_filesto serve static assets from the root.src/app.rs:spin_sdk::key_value::Store(e.g.open_default(),get_json(),set_json(),delete()) to be.awaited, as they are now asynchronous in Spin SDK v6.0.0.spin_sdk::variables::get("agent_server_url")inside component functions with context-based routing (use_context::<AgentServerUrl>()) to facilitate isomorphic SSR/client operations.let _ = id; let _ = call_id;) insideToolCallViewto eliminate compile-time warnings while preserving auto-generated component properties.