diff --git a/src/app_service.rs b/src/app_service.rs index ca6f36202..5301e0e02 100644 --- a/src/app_service.rs +++ b/src/app_service.rs @@ -90,7 +90,7 @@ where .into_iter() .map(|(mut rdef, srv, guards, nested)| { rmap.add(&mut rdef, nested); - (rdef, srv, RefCell::new(guards)) + (rdef, srv, guards.map(Rc::new)) }) .collect::>() .into_boxed_slice() @@ -228,7 +228,7 @@ where } pub struct AppRoutingFactory { - services: Rc<[(ResourceDef, HttpNewService, RefCell>)]>, + services: Rc<[(ResourceDef, HttpNewService, Option>)]>, default: Rc, } @@ -244,7 +244,7 @@ impl ServiceFactory for AppRoutingFactory { // construct all services factory future with it's resource def and guards. let factory_fut = join_all(self.services.iter().map(|(path, factory, guards)| { let path = path.clone(); - let guards = guards.borrow_mut().take(); + let guards = guards.clone(); let factory_fut = factory.new_service(()); async move { let service = factory_fut.await?; @@ -276,7 +276,7 @@ impl ServiceFactory for AppRoutingFactory { } pub struct AppRouting { - router: Router, + router: Router>, default: HttpService, } @@ -290,7 +290,7 @@ impl Service for AppRouting { fn call(&self, mut req: ServiceRequest) -> Self::Future { let res = self.router.recognize_checked(&mut req, |req, guards| { if let Some(ref guards) = guards { - for f in guards { + for f in guards.iter() { if !f.check(req.head()) { return false; } diff --git a/src/scope.rs b/src/scope.rs index 412c01d95..be624f0cd 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -432,7 +432,7 @@ where .into_iter() .map(|(mut rdef, srv, guards, nested)| { rmap.add(&mut rdef, nested); - (rdef, srv, RefCell::new(guards)) + (rdef, srv, guards.map(Rc::new)) }) .collect::>() .into_boxed_slice() @@ -458,7 +458,7 @@ where pub struct ScopeFactory { app_data: Option>, - services: Rc<[(ResourceDef, HttpNewService, RefCell>)]>, + services: Rc<[(ResourceDef, HttpNewService, Option>)]>, default: Rc, } @@ -477,7 +477,7 @@ impl ServiceFactory for ScopeFactory { // construct all services factory future with it's resource def and guards. let factory_fut = join_all(self.services.iter().map(|(path, factory, guards)| { let path = path.clone(); - let guards = guards.borrow_mut().take(); + let guards = guards.clone(); let factory_fut = factory.new_service(()); async move { let service = factory_fut.await?; @@ -513,7 +513,7 @@ impl ServiceFactory for ScopeFactory { pub struct ScopeService { app_data: Option>, - router: Router>>, + router: Router>, default: HttpService, } @@ -527,7 +527,7 @@ impl Service for ScopeService { fn call(&self, mut req: ServiceRequest) -> Self::Future { let res = self.router.recognize_checked(&mut req, |req, guards| { if let Some(ref guards) = guards { - for f in guards { + for f in guards.iter() { if !f.check(req.head()) { return false; }