diff --git a/README.md b/README.md index a176207..61fd0b1 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ - [Extractors](#extractors) - [Responders](#responders) - [Request Guards](#request-guards) + - [Macroses](#macroses) - [Examples](#examples) - [Example: Extractors](#example-extractors) - [Example: Responders](#example-responders) @@ -89,6 +90,12 @@ trivially set the `HX-Request` header themselves. This is merely a convenience for preventing users from receiving partial responses without context. If you need to secure an endpoint you should be using a proper auth system._ +## Macroses + +__Requires features `macros`.__ + +In addition to the HxBoosted extractor, the library provides macroses `hx_boosted_by` and it's async version `hx_boosted_by_async` for managing the response based on the presence of the `HX-Boosted` header. + ## Examples ### Example: Extractors @@ -185,6 +192,26 @@ fn router_two() -> Router { } ``` +### Example: Macros + +```rust +use axum_htmx::hx_boosted_by; + +#[hx_boosted_by(with_layout)] +async fn get_hello(Path(name): Path) -> Html { + Html(format!("Hello, {}!", name) +} + +#[hx_boosted_by(with_layout)] +async fn get_bye(Path(name): Path) -> Html { + Html(format!("Bye, {}!", name) +} + +fn with_layout(Html(partial): Html) -> Html { + Html(format!("{}", partial)) +} +``` + ## Feature Flags