Skip to content

Commit efc1f57

Browse files
authored
Use extensions directly in from_request_parts (#3542)
1 parent c4890b8 commit efc1f57

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

axum-extra/src/extract/cached.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use axum::extract::{Extension, FromRequestParts};
1+
use axum::extract::FromRequestParts;
22
use http::request::Parts;
33

44
/// Cache results of other extractors.
@@ -88,10 +88,8 @@ where
8888
type Rejection = T::Rejection;
8989

9090
async fn from_request_parts(parts: &mut Parts, state: &S) -> Result<Self, Self::Rejection> {
91-
if let Ok(Extension(CachedEntry(value))) =
92-
Extension::<CachedEntry<T>>::from_request_parts(parts, state).await
93-
{
94-
Ok(Self(value))
91+
if let Some(value) = parts.extensions.get::<CachedEntry<T>>() {
92+
Ok(Self(value.0.clone()))
9593
} else {
9694
let value = T::from_request_parts(parts, state).await?;
9795
parts.extensions.insert(CachedEntry(value.clone()));

0 commit comments

Comments
 (0)