Skip to content

Commit

Permalink
Update doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
robertwayne committed Jun 24, 2024
1 parent d36468f commit f4871d6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/auto_vary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const MIDDLEWARE_DOUBLE_USE: &str =
"Configuration error: `axum_httpx::vary_middleware` is used twice";

/// Addresses [htmx caching issue](https://htmx.org/docs/#caching)
/// by automatically adding a corresponding `Vary` header when [`HxRequest`], [`HxTarget`],
/// [`HxTrigger`], [`HxTriggerName`] or their combination is used.
/// by automatically adding a corresponding `Vary` header when [`HxRequest`],
/// [`HxTarget`], [`HxTrigger`], [`HxTriggerName`] or their combination is used.
#[derive(Clone)]
pub struct AutoVaryLayer;

Expand Down
33 changes: 19 additions & 14 deletions src/responders/vary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ const HX_TRIGGER_NAME: HeaderValue = HeaderValue::from_static(headers::HX_TRIGGE

/// The `Vary: HX-Request` header.
///
/// You may want to add this header to the response if your handler responds differently based on
/// the `HX-Request` request header.
/// You may want to add this header to the response if your handler responds
/// differently based on the `HX-Request` request header.
///
/// For example, if your server renders the full HTML when the `HX-Request` header is missing or
/// `false`, and it renders a fragment of that HTML when `HX-Request: true`.
/// For example, if your server renders the full HTML when the `HX-Request`
/// header is missing or `false`, and it renders a fragment of that HTML when
/// `HX-Request: true`.
///
/// You probably need this only for `GET` requests, as other HTTP methods are not cached by default.
/// You probably need this only for `GET` requests, as other HTTP methods are
/// not cached by default.
///
/// See <https://htmx.org/docs/#caching> for more information.
#[derive(Debug, Clone)]
Expand All @@ -41,10 +43,11 @@ impl extractors::HxRequest {

/// The `Vary: HX-Target` header.
///
/// You may want to add this header to the response if your handler responds differently based on
/// the `HX-Target` request header.
/// You may want to add this header to the response if your handler responds
/// differently based on the `HX-Target` request header.
///
/// You probably need this only for `GET` requests, as other HTTP methods are not cached by default.
/// You probably need this only for `GET` requests, as other HTTP methods are
/// not cached by default.
///
/// See <https://htmx.org/docs/#caching> for more information.
#[derive(Debug, Clone)]
Expand All @@ -69,10 +72,11 @@ impl extractors::HxTarget {

/// The `Vary: HX-Trigger` header.
///
/// You may want to add this header to the response if your handler responds differently based on
/// the `HX-Trigger` request header.
/// You may want to add this header to the response if your handler responds
/// differently based on the `HX-Trigger` request header.
///
/// You probably need this only for `GET` requests, as other HTTP methods are not cached by default.
/// You probably need this only for `GET` requests, as other HTTP methods are
/// not cached by default.
///
/// See <https://htmx.org/docs/#caching> for more information.
#[derive(Debug, Clone)]
Expand All @@ -97,10 +101,11 @@ impl extractors::HxTrigger {

/// The `Vary: HX-Trigger-Name` header.
///
/// You may want to add this header to the response if your handler responds differently based on
/// the `HX-Trigger-Name` request header.
/// You may want to add this header to the response if your handler responds
/// differently based on the `HX-Trigger-Name` request header.
///
/// You probably need this only for `GET` requests, as other HTTP methods are not cached by default.
/// You probably need this only for `GET` requests, as other HTTP methods are
/// not cached by default.
///
/// See <https://htmx.org/docs/#caching> for more information.
#[derive(Debug, Clone)]
Expand Down

0 comments on commit f4871d6

Please sign in to comment.