File tree 2 files changed +4
-6
lines changed
2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -86,11 +86,11 @@ impl AllowOrigin {
86
86
/// [`CorsLayer::allow_origin`]: super::CorsLayer::allow_origin
87
87
pub fn async_predicate < F , Fut > ( f : F ) -> Self
88
88
where
89
- F : Fn ( & HeaderValue , & RequestParts ) -> Fut + Send + Sync + ' static ,
89
+ F : FnOnce ( HeaderValue , & RequestParts ) -> Fut + Send + Sync + ' static + Clone ,
90
90
Fut : Future < Output = bool > + Send + Sync + ' static ,
91
91
{
92
92
Self ( OriginInner :: AsyncPredicate ( Arc :: new ( move |v, p| {
93
- Box :: pin ( f ( v, p) )
93
+ Box :: pin ( ( f . clone ( ) ) ( v, p) )
94
94
} ) ) )
95
95
}
96
96
@@ -130,7 +130,7 @@ impl AllowOrigin {
130
130
) ,
131
131
OriginInner :: AsyncPredicate ( f) => {
132
132
if let Some ( origin) = origin. cloned ( ) {
133
- let fut = f ( & origin, parts) ;
133
+ let fut = f ( origin. clone ( ) , parts) ;
134
134
AllowOriginFuture :: fut ( async move { fut. await . then_some ( ( name, origin) ) } )
135
135
} else {
136
136
AllowOriginFuture :: ok ( None )
@@ -224,7 +224,7 @@ enum OriginInner {
224
224
AsyncPredicate (
225
225
Arc <
226
226
dyn for < ' a > Fn (
227
- & ' a HeaderValue ,
227
+ HeaderValue ,
228
228
& ' a RequestParts ,
229
229
) -> Pin < Box < dyn Future < Output = bool > + Send + ' static > >
230
230
+ Send
Original file line number Diff line number Diff line change @@ -46,8 +46,6 @@ async fn test_allow_origin_async_predicate() {
46
46
let client = Client ;
47
47
48
48
let allow_origin = AllowOrigin :: async_predicate ( move |origin, parts| {
49
- let origin = origin. clone ( ) ;
50
- let client = client. clone ( ) ;
51
49
let path = parts. uri . path ( ) . to_owned ( ) ;
52
50
53
51
async move {
You can’t perform that action at this time.
0 commit comments