mirror of
https://github.com/robertwayne/axum-htmx
synced 2024-11-29 14:44:33 +01:00
Update doc comments
This commit is contained in:
parent
b15c850197
commit
d36468f9d5
2 changed files with 5 additions and 5 deletions
|
@ -19,16 +19,16 @@ async fn main() {
|
||||||
serve(listener, app).await.unwrap();
|
serve(listener, app).await.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Our handler differentiates full-page GET requests from HTMx-based ones by looking at the `hx-request`
|
// Our handler differentiates full-page GET requests from htmx-based ones by looking at the `hx-request`
|
||||||
// requestheader.
|
// requestheader.
|
||||||
//
|
//
|
||||||
// The middleware sees the usage of the `HxRequest` extractor and automatically adds the
|
// The middleware sees the usage of the `HxRequest` extractor and automatically adds the
|
||||||
// `Vary: hx-request` response header.
|
// `Vary: hx-request` response header.
|
||||||
async fn handler(HxRequest(hx_request): HxRequest) -> Html<&'static str> {
|
async fn handler(HxRequest(hx_request): HxRequest) -> Html<&'static str> {
|
||||||
if hx_request {
|
if hx_request {
|
||||||
// For HTMx-based GET request, it returns a partial page update
|
// For htmx-based GET request, it returns a partial page update
|
||||||
sleep(Duration::from_secs(3)).await;
|
sleep(Duration::from_secs(3)).await;
|
||||||
return Html("HTMx response");
|
return Html("htmx response");
|
||||||
}
|
}
|
||||||
// While for a normal GET request, it returns the whole page
|
// While for a normal GET request, it returns the whole page
|
||||||
Html(
|
Html(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//! A middleware to automatically add a `Vary` header when needed to address
|
//! A middleware to automatically add a `Vary` header when needed to address
|
||||||
//! [HTMx caching issue](https://htmx.org/docs/#caching)
|
//! [htmx caching issue](https://htmx.org/docs/#caching)
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
|
@ -28,7 +28,7 @@ use crate::{HxRequest, HxTarget, HxTrigger, HxTriggerName};
|
||||||
const MIDDLEWARE_DOUBLE_USE: &str =
|
const MIDDLEWARE_DOUBLE_USE: &str =
|
||||||
"Configuration error: `axum_httpx::vary_middleware` is used twice";
|
"Configuration error: `axum_httpx::vary_middleware` is used twice";
|
||||||
|
|
||||||
/// Addresses [HTMx caching issue](https://htmx.org/docs/#caching)
|
/// Addresses [htmx caching issue](https://htmx.org/docs/#caching)
|
||||||
/// by automatically adding a corresponding `Vary` header when [`HxRequest`], [`HxTarget`],
|
/// by automatically adding a corresponding `Vary` header when [`HxRequest`], [`HxTarget`],
|
||||||
/// [`HxTrigger`], [`HxTriggerName`] or their combination is used.
|
/// [`HxTrigger`], [`HxTriggerName`] or their combination is used.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|
Loading…
Reference in a new issue