From 5b24a9522d3f1cd0fbaaf0b47b60010e9e559818 Mon Sep 17 00:00:00 2001 From: Rob Wagner Date: Mon, 13 May 2024 18:42:45 -0400 Subject: [PATCH] Fix typing mismatch If we're going to use typed header names and values, we'll have to duplicate some of the string literals across the two. Not a big deal. --- src/responders/vary.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/responders/vary.rs b/src/responders/vary.rs index 03866da..48eee24 100644 --- a/src/responders/vary.rs +++ b/src/responders/vary.rs @@ -1,12 +1,12 @@ use axum_core::response::{IntoResponseParts, ResponseParts}; use http::header::{HeaderValue, VARY}; -use crate::{extractors, headers, HxError}; +use crate::{extractors, HxError}; -const HX_REQUEST: HeaderValue = HeaderValue::from_static(headers::HX_REQUEST); -const HX_TARGET: HeaderValue = HeaderValue::from_static(headers::HX_TARGET); -const HX_TRIGGER: HeaderValue = HeaderValue::from_static(headers::HX_TRIGGER); -const HX_TRIGGER_NAME: HeaderValue = HeaderValue::from_static(headers::HX_TRIGGER_NAME); +const HX_REQUEST: HeaderValue = HeaderValue::from_static("hx-request"); +const HX_TARGET: HeaderValue = HeaderValue::from_static("hx-target"); +const HX_TRIGGER: HeaderValue = HeaderValue::from_static("hx-trigger"); +const HX_TRIGGER_NAME: HeaderValue = HeaderValue::from_static("hx-trigger-name"); /// The `Vary: HX-Request` header. /// @@ -125,10 +125,12 @@ impl extractors::HxTriggerName { #[cfg(test)] mod tests { - use super::*; - use axum::{routing::get, Router}; use std::collections::hash_set::HashSet; + use axum::{routing::get, Router}; + + use super::*; + #[tokio::test] async fn multiple_headers() { let app = Router::new().route("/", get(|| async { (VaryHxRequest, VaryHxTarget, "foo") }));