Skip to content

Commit

Permalink
Fix typing mismatch
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
robertwayne committed May 13, 2024
1 parent a81dff4 commit 5b24a95
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/responders/vary.rs
Original file line number Diff line number Diff line change
@@ -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.
///
Expand Down Expand Up @@ -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") }));
Expand Down

0 comments on commit 5b24a95

Please sign in to comment.