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))
|
||||
}
|
||||
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];
|
||||
pattern.find(path).map(|m| m.end())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -260,48 +257,39 @@ impl ResourceDef {
|
|||
(min(path.len(), len), None)
|
||||
}
|
||||
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() {
|
||||
if let Some(m) = captures.name(&name) {
|
||||
segments[no] = PathItem::Segment(m.start() as u16, m.end() as u16);
|
||||
} else {
|
||||
log::error!(
|
||||
"Dynamic path match but not all segments found: {}",
|
||||
name
|
||||
);
|
||||
log::error!("Dynamic path match but not all segments found: {}", name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
(captures[0].len(), Some(names))
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
PatternType::DynamicSet(ref re, ref params) => {
|
||||
let path = path.path();
|
||||
if let Some(idx) = re.matches(path).into_iter().next() {
|
||||
let (ref pattern, ref names) = params[idx];
|
||||
|
||||
if let Some(captures) = pattern.captures(path) {
|
||||
let (pattern, names) = match re.matches(path).into_iter().next() {
|
||||
Some(idx) => ¶ms[idx],
|
||||
_ => return false,
|
||||
};
|
||||
let captures = match pattern.captures(path.path()) {
|
||||
Some(captures) => captures,
|
||||
_ => return false,
|
||||
};
|
||||
for (no, name) in names.iter().enumerate() {
|
||||
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 {
|
||||
log::error!(
|
||||
"Dynamic path match but not all segments found: {}",
|
||||
name
|
||||
);
|
||||
log::error!("Dynamic path match but not all segments found: {}", name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
(captures[0].len(), Some(names))
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue