Expand description
HTMX response types and extractors
This module builds on axum-htmx with additional features:
- Out-of-band swaps (
HxSwapOob) - Automatic template detection (
HxTemplate) - Smart response enum (
HxResponse)
§Re-exported from axum-htmx
All request extractors and response helpers from axum-htmx are re-exported
for convenience. See axum-htmx documentation for
detailed usage.
§Out-of-Band Swaps
Use HxSwapOob to update multiple page elements in a single response:
use acton_htmx::htmx::{HxSwapOob, SwapStrategy};
use axum::response::Html;
async fn update_with_oob() -> impl axum::response::IntoResponse {
let mut oob = HxSwapOob::new();
// Update main content
oob.add("main-content", "<p>New main content</p>", SwapStrategy::InnerHTML);
// Update notification badge
oob.add("notification-count", "<span>5</span>", SwapStrategy::InnerHTML);
// Update flash messages
oob.add("flash-container", r#"<div class="alert">Success!</div>"#, SwapStrategy::InnerHTML);
oob
}Structs§
- Auto
Vary Layer - Addresses htmx caching issues
by automatically adding a corresponding
Varyheader when [HxRequest], [HxTarget], [HxTrigger], [HxTriggerName] or their combination is used. - HxBoosted
- The
HX-Boostedheader. - HxCurrent
Url - The
HX-Current-Urlheader. - HxHistory
Restore Request - The
HX-History-Restore-Requestheader. - HxLocation
- The
HX-Locationheader. - HxPrompt
- The
HX-Promptheader. - HxPush
Url - The
HX-Push-Urlheader. - HxRedirect
- The
HX-Redirectheader. - HxRefresh
- The
HX-Refreshheader. - HxReplace
Url - The
HX-Replace-Urlheader. - HxRequest
- The
HX-Requestheader. - HxRequest
Guard Layer - Checks if the request contains the
HX-Requestheader, redirecting to the given location if not. - HxReselect
- The
HX-Reselectheader. - HxResponse
Trigger - The
HX-Trigger*header. - HxReswap
- The
HX-Reswapheader. - HxRetarget
- The
HX-Retargetheader. - HxSwap
Oob - Out-of-band swap container
- HxTarget
- The
HX-Targetheader. - HxTrigger
- The
HX-Triggerheader. - HxTrigger
Name - The
HX-Trigger-Nameheader.
Enums§
- Swap
Strategy - HTMX swap strategy for out-of-band updates