Skip to content

Commit

Permalink
update method name to more appropriate one
Browse files Browse the repository at this point in the history
  • Loading branch information
PoOnesNerfect committed Mar 8, 2024
1 parent 5e87a5f commit 2d2d436
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions tower-http/src/cors/allow_origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl AllowOrigin {
matches!(&self.0, OriginInner::Const(v) if v == WILDCARD)
}

pub(super) fn to_header(
pub(super) fn to_future(
&self,
origin: Option<&HeaderValue>,
parts: &RequestParts,
Expand Down Expand Up @@ -184,7 +184,7 @@ impl fmt::Debug for AllowOrigin {
OriginInner::Const(inner) => f.debug_tuple("Const").field(inner).finish(),
OriginInner::List(inner) => f.debug_tuple("List").field(inner).finish(),
OriginInner::Predicate(_) => f.debug_tuple("Predicate").finish(),
OriginInner::AsyncPredicate(_) => f.debug_tuple("Future").finish(),
OriginInner::AsyncPredicate(_) => f.debug_tuple("AsyncPredicate").finish(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tower-http/src/cors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ where
headers.extend(self.layer.allow_private_network.to_header(origin, &parts));
headers.extend(self.layer.vary.to_header());

let allow_origin_future = self.layer.allow_origin.to_header(origin, &parts);
let allow_origin_future = self.layer.allow_origin.to_future(origin, &parts);

// Return results immediately upon preflight request
if parts.method == Method::OPTIONS {
Expand Down
4 changes: 2 additions & 2 deletions tower-http/src/cors/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async fn test_allow_origin_async_predicate() {
let parts = http::Request::new("hello world").into_parts().0;

let header = allow_origin
.to_header(Some(&valid_origin), &parts)
.to_future(Some(&valid_origin), &parts)
.await
.unwrap();
assert_eq!(header.0, header::ACCESS_CONTROL_ALLOW_ORIGIN);
Expand All @@ -70,6 +70,6 @@ async fn test_allow_origin_async_predicate() {
let invalid_origin = HeaderValue::from_static("http://example.org");
let parts = http::Request::new("hello world").into_parts().0;

let res = allow_origin.to_header(Some(&invalid_origin), &parts).await;
let res = allow_origin.to_future(Some(&invalid_origin), &parts).await;
assert!(res.is_none());
}

0 comments on commit 2d2d436

Please sign in to comment.