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.
This commit is contained in:
Rob Wagner 2024-05-13 18:42:45 -04:00
parent a81dff414c
commit 5b24a9522d
No known key found for this signature in database
GPG key ID: 53CCB4497B15CF61

View file

@ -1,12 +1,12 @@
use axum_core::response::{IntoResponseParts, ResponseParts}; use axum_core::response::{IntoResponseParts, ResponseParts};
use http::header::{HeaderValue, VARY}; 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_REQUEST: HeaderValue = HeaderValue::from_static("hx-request");
const HX_TARGET: HeaderValue = HeaderValue::from_static(headers::HX_TARGET); const HX_TARGET: HeaderValue = HeaderValue::from_static("hx-target");
const HX_TRIGGER: HeaderValue = HeaderValue::from_static(headers::HX_TRIGGER); const HX_TRIGGER: HeaderValue = HeaderValue::from_static("hx-trigger");
const HX_TRIGGER_NAME: HeaderValue = HeaderValue::from_static(headers::HX_TRIGGER_NAME); const HX_TRIGGER_NAME: HeaderValue = HeaderValue::from_static("hx-trigger-name");
/// The `Vary: HX-Request` header. /// The `Vary: HX-Request` header.
/// ///
@ -125,10 +125,12 @@ impl extractors::HxTriggerName {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
use axum::{routing::get, Router};
use std::collections::hash_set::HashSet; use std::collections::hash_set::HashSet;
use axum::{routing::get, Router};
use super::*;
#[tokio::test] #[tokio::test]
async fn multiple_headers() { async fn multiple_headers() {
let app = Router::new().route("/", get(|| async { (VaryHxRequest, VaryHxTarget, "foo") })); let app = Router::new().route("/", get(|| async { (VaryHxRequest, VaryHxTarget, "foo") }));