1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-25 18:09:22 +02:00

Fix scope resource path extractor #234

This commit is contained in:
Nikolay Kim
2018-05-20 17:04:08 -07:00
parent f32e8f22c8
commit 082ff46041
4 changed files with 88 additions and 0 deletions

View File

@ -58,6 +58,16 @@ impl<'a> Params<'a> {
self.0.push((name, value));
}
pub(crate) fn remove(&mut self, name: &str)
{
for idx in (0..self.0.len()).rev() {
if self.0[idx].0 == name {
self.0.remove(idx);
return
}
}
}
/// Check if there are any matched patterns
pub fn is_empty(&self) -> bool {
self.0.is_empty()

View File

@ -336,6 +336,7 @@ impl<S: 'static> RouteHandler<S> for Scope<S> {
if pattern.match_with_params(path, req.match_info_mut()) {
let default = unsafe { &mut *self.default.as_ref().get() };
req.match_info_mut().remove("tail");
if self.middlewares.is_empty() {
let resource = unsafe { &mut *resource.get() };
return resource.handle(req, Some(default));