mirror of https://github.com/fafhrd91/actix-web
fix(guards): replace take_guards with get_guards to prevent guard removal and fix test failures
This commit is contained in:
parent
819ee93e9b
commit
91fa813f0e
|
@ -11,7 +11,7 @@
|
|||
//! or handler. This interface is defined by the [`Guard`] trait.
|
||||
//!
|
||||
//! Commonly-used guards are provided in this module as well as a way of creating a guard from a
|
||||
//! closure ([`fn_guard`]). The [`Not`], [`Any`], and [`All`] guards are noteworthy, as they can be
|
||||
//! closure ([`fn_guard`]). The [`Not`], [`Any()`], and [`All`] guards are noteworthy, as they can be
|
||||
//! used to compose other guards in a more flexible and semantic way than calling `.guard(...)` on
|
||||
//! services multiple times (which might have different combining behavior than you want).
|
||||
//!
|
||||
|
|
|
@ -442,8 +442,8 @@ where
|
|||
{
|
||||
rmap.add(&mut rdef, None);
|
||||
|
||||
self.routes.iter_mut().for_each(|r| {
|
||||
r.take_guards().iter().for_each(|g| {
|
||||
self.routes.iter().for_each(|r| {
|
||||
r.get_guards().iter().for_each(|g| {
|
||||
let http_methods: Vec<String> =
|
||||
crate::guard::HttpMethodsExtractor::extract_http_methods(&**g);
|
||||
rdef_methods
|
||||
|
|
|
@ -65,6 +65,11 @@ impl Route {
|
|||
pub(crate) fn take_guards(&mut self) -> Vec<Box<dyn Guard>> {
|
||||
mem::take(Rc::get_mut(&mut self.guards).unwrap())
|
||||
}
|
||||
|
||||
#[cfg(feature = "resources-introspection")]
|
||||
pub(crate) fn get_guards(&self) -> &Vec<Box<dyn Guard>> {
|
||||
&self.guards
|
||||
}
|
||||
}
|
||||
|
||||
impl ServiceFactory<ServiceRequest> for Route {
|
||||
|
|
Loading…
Reference in New Issue