mirror of https://github.com/fafhrd91/actix-net
cleanup redundant tail code
This commit is contained in:
parent
adf4867f28
commit
5ddbccd07e
|
@ -6,7 +6,8 @@
|
||||||
* Path tail pattern now works as expected after a dynamic segment (e.g. `/user/{uid}/*`). [#366]
|
* Path tail pattern now works as expected after a dynamic segment (e.g. `/user/{uid}/*`). [#366]
|
||||||
* Fix a bug in multi-patterns where static patterns are interpreted as regex. [#366]
|
* Fix a bug in multi-patterns where static patterns are interpreted as regex. [#366]
|
||||||
* Fix `ResourceDef` `PartialEq` implementation.
|
* Fix `ResourceDef` `PartialEq` implementation.
|
||||||
* Re-work `IntoPatterns` trait. [#372]
|
* Re-work `IntoPatterns` trait, adding a `Patterns` enum. [#372]
|
||||||
|
* Implement `IntoPatterns` for `bytestring::ByteString`. [#372]
|
||||||
* Rename `Path::{len => segment_count}` to be more descriptive of it's purpose. [#370]
|
* Rename `Path::{len => segment_count}` to be more descriptive of it's purpose. [#370]
|
||||||
* Rename `ResourceDef::{resource_path => resource_path_from_iter}`. [#371]
|
* Rename `ResourceDef::{resource_path => resource_path_from_iter}`. [#371]
|
||||||
* Rename `ResourceDef::{resource_path_named => resource_path_from_map}`. [#371]
|
* Rename `ResourceDef::{resource_path_named => resource_path_from_map}`. [#371]
|
||||||
|
|
|
@ -26,7 +26,6 @@ pub struct Path<T> {
|
||||||
path: T,
|
path: T,
|
||||||
pub(crate) skip: u16,
|
pub(crate) skip: u16,
|
||||||
pub(crate) segments: Vec<(Cow<'static, str>, PathItem)>,
|
pub(crate) segments: Vec<(Cow<'static, str>, PathItem)>,
|
||||||
pub(crate) tail: Option<PathItem>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: ResourcePath> Path<T> {
|
impl<T: ResourcePath> Path<T> {
|
||||||
|
@ -35,7 +34,6 @@ impl<T: ResourcePath> Path<T> {
|
||||||
path,
|
path,
|
||||||
skip: 0,
|
skip: 0,
|
||||||
segments: Vec::new(),
|
segments: Vec::new(),
|
||||||
tail: None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,11 +96,6 @@ impl<T: ResourcePath> Path<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn add_tail(&mut self, value: PathItem) {
|
|
||||||
profile_method!(add_tail);
|
|
||||||
self.tail = Some(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub fn add_static(
|
pub fn add_static(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
|
@ -717,12 +717,12 @@ impl ResourceDef {
|
||||||
let path = resource.resource_path();
|
let path = resource.resource_path();
|
||||||
let path_str = path.path();
|
let path_str = path.path();
|
||||||
|
|
||||||
let (matched_len, matched_vars, tail) = match &self.pat_type {
|
let (matched_len, matched_vars) = match &self.pat_type {
|
||||||
PatternType::Static(_) | PatternType::Prefix(_) => {
|
PatternType::Static(_) | PatternType::Prefix(_) => {
|
||||||
profile_section!(pattern_static_or_prefix);
|
profile_section!(pattern_static_or_prefix);
|
||||||
|
|
||||||
match self.find_match(path_str) {
|
match self.find_match(path_str) {
|
||||||
Some(len) => (len, None, None),
|
Some(len) => (len, None),
|
||||||
None => return false,
|
None => return false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -755,7 +755,7 @@ impl ResourceDef {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
(captures[0].len(), Some(names), None)
|
(captures[0].len(), Some(names))
|
||||||
}
|
}
|
||||||
|
|
||||||
PatternType::DynamicSet(re, params) => {
|
PatternType::DynamicSet(re, params) => {
|
||||||
|
@ -781,7 +781,7 @@ impl ResourceDef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(captures[0].len(), Some(names), None)
|
(captures[0].len(), Some(names))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -798,10 +798,6 @@ impl ResourceDef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(tail) = tail {
|
|
||||||
path.add_tail(tail)
|
|
||||||
}
|
|
||||||
|
|
||||||
path.skip(matched_len as u16);
|
path.skip(matched_len as u16);
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|
Loading…
Reference in New Issue