acton_htmx/htmx/mod.rs
1//! HTMX response types and extractors
2//!
3//! This module builds on `axum-htmx` with additional features:
4//! - Out-of-band swaps (`HxSwapOob`)
5//! - Automatic template detection (`HxTemplate`)
6//! - Smart response enum (`HxResponse`)
7//!
8//! # Re-exported from axum-htmx
9//!
10//! All request extractors and response helpers from `axum-htmx` are re-exported
11//! for convenience. See [axum-htmx documentation](https://docs.rs/axum-htmx) for
12//! detailed usage.
13//!
14//! # Out-of-Band Swaps
15//!
16//! Use [`HxSwapOob`] to update multiple page elements in a single response:
17//!
18//! ```rust,no_run
19//! use acton_htmx::htmx::{HxSwapOob, SwapStrategy};
20//! use axum::response::Html;
21//!
22//! async fn update_with_oob() -> impl axum::response::IntoResponse {
23//! let mut oob = HxSwapOob::new();
24//!
25//! // Update main content
26//! oob.add("main-content", "<p>New main content</p>", SwapStrategy::InnerHTML);
27//!
28//! // Update notification badge
29//! oob.add("notification-count", "<span>5</span>", SwapStrategy::InnerHTML);
30//!
31//! // Update flash messages
32//! oob.add("flash-container", r#"<div class="alert">Success!</div>"#, SwapStrategy::InnerHTML);
33//!
34//! oob
35//! }
36//! ```
37
38// Re-export axum-htmx request extractors
39pub use axum_htmx::{
40 HxBoosted, HxCurrentUrl, HxHistoryRestoreRequest, HxPrompt, HxRequest, HxTarget, HxTrigger,
41 HxTriggerName,
42};
43
44// Re-export axum-htmx response helpers
45pub use axum_htmx::{
46 HxLocation, HxPushUrl, HxRedirect, HxRefresh, HxReplaceUrl, HxReselect, HxResponseTrigger,
47 HxReswap, HxRetarget,
48};
49
50// Re-export axum-htmx middleware and guards
51pub use axum_htmx::{AutoVaryLayer, HxRequestGuardLayer};
52
53// acton-htmx extensions
54mod swap_oob;
55pub use swap_oob::{HxSwapOob, SwapStrategy};