mirror of
https://github.com/robertwayne/axum-htmx
synced 2024-12-27 18:59:32 +01:00
Added hx_boosted_by docs into README
This commit is contained in:
parent
7ef8f4485c
commit
6be4fcfb23
1 changed files with 27 additions and 0 deletions
27
README.md
27
README.md
|
@ -24,6 +24,7 @@
|
||||||
- [Extractors](#extractors)
|
- [Extractors](#extractors)
|
||||||
- [Responders](#responders)
|
- [Responders](#responders)
|
||||||
- [Request Guards](#request-guards)
|
- [Request Guards](#request-guards)
|
||||||
|
- [Macroses](#macroses)
|
||||||
- [Examples](#examples)
|
- [Examples](#examples)
|
||||||
- [Example: Extractors](#example-extractors)
|
- [Example: Extractors](#example-extractors)
|
||||||
- [Example: Responders](#example-responders)
|
- [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
|
for preventing users from receiving partial responses without context. If you
|
||||||
need to secure an endpoint you should be using a proper auth system._
|
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
|
## Examples
|
||||||
|
|
||||||
### Example: Extractors
|
### 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<String>) -> Html<String> {
|
||||||
|
Html(format!("Hello, {}!", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[hx_boosted_by(with_layout)]
|
||||||
|
async fn get_bye(Path(name): Path<String>) -> Html<String> {
|
||||||
|
Html(format!("Bye, {}!", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn with_layout(Html(partial): Html<String>) -> Html<String> {
|
||||||
|
Html(format!("<html><body>{}</body></html>", partial))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Feature Flags
|
## Feature Flags
|
||||||
|
|
||||||
<!-- markdownlint-disable -->
|
<!-- markdownlint-disable -->
|
||||||
|
|
Loading…
Reference in a new issue