mirror of https://github.com/fafhrd91/actix-net
flatten
This commit is contained in:
parent
515e1089b1
commit
ceb91bb31f
|
@ -203,12 +203,9 @@ impl ResourceDef {
|
||||||
Some(min(p_len, len))
|
Some(min(p_len, len))
|
||||||
}
|
}
|
||||||
PatternType::DynamicSet(ref re, ref params) => {
|
PatternType::DynamicSet(ref re, ref params) => {
|
||||||
if let Some(idx) = re.matches(path).into_iter().next() {
|
let idx = re.matches(path).into_iter().next()?;
|
||||||
let (ref pattern, _) = params[idx];
|
let (ref pattern, _) = params[idx];
|
||||||
pattern.find(path).map(|m| m.end())
|
pattern.find(path).map(|m| m.end())
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,48 +257,39 @@ impl ResourceDef {
|
||||||
(min(path.len(), len), None)
|
(min(path.len(), len), None)
|
||||||
}
|
}
|
||||||
PatternType::Dynamic(ref re, ref names) => {
|
PatternType::Dynamic(ref re, ref names) => {
|
||||||
if let Some(captures) = re.captures(path.path()) {
|
let captures = match re.captures(path.path()) {
|
||||||
|
Some(captures) => captures,
|
||||||
|
_ => return false,
|
||||||
|
};
|
||||||
for (no, name) in names.iter().enumerate() {
|
for (no, name) in names.iter().enumerate() {
|
||||||
if let Some(m) = captures.name(&name) {
|
if let Some(m) = captures.name(&name) {
|
||||||
segments[no] = PathItem::Segment(m.start() as u16, m.end() as u16);
|
segments[no] = PathItem::Segment(m.start() as u16, m.end() as u16);
|
||||||
} else {
|
} else {
|
||||||
log::error!(
|
log::error!("Dynamic path match but not all segments found: {}", name);
|
||||||
"Dynamic path match but not all segments found: {}",
|
|
||||||
name
|
|
||||||
);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(captures[0].len(), Some(names))
|
(captures[0].len(), Some(names))
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
PatternType::DynamicSet(ref re, ref params) => {
|
PatternType::DynamicSet(ref re, ref params) => {
|
||||||
let path = path.path();
|
let path = path.path();
|
||||||
if let Some(idx) = re.matches(path).into_iter().next() {
|
let (pattern, names) = match re.matches(path).into_iter().next() {
|
||||||
let (ref pattern, ref names) = params[idx];
|
Some(idx) => ¶ms[idx],
|
||||||
|
_ => return false,
|
||||||
if let Some(captures) = pattern.captures(path) {
|
};
|
||||||
|
let captures = match pattern.captures(path.path()) {
|
||||||
|
Some(captures) => captures,
|
||||||
|
_ => return false,
|
||||||
|
};
|
||||||
for (no, name) in names.iter().enumerate() {
|
for (no, name) in names.iter().enumerate() {
|
||||||
if let Some(m) = captures.name(&name) {
|
if let Some(m) = captures.name(&name) {
|
||||||
segments[no] =
|
segments[no] = PathItem::Segment(m.start() as u16, m.end() as u16);
|
||||||
PathItem::Segment(m.start() as u16, m.end() as u16);
|
|
||||||
} else {
|
} else {
|
||||||
log::error!(
|
log::error!("Dynamic path match but not all segments found: {}", name);
|
||||||
"Dynamic path match but not all segments found: {}",
|
|
||||||
name
|
|
||||||
);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(captures[0].len(), Some(names))
|
(captures[0].len(), Some(names))
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue