1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-25 06:39:22 +02:00
This commit is contained in:
Rob Ede
2021-10-19 01:32:58 +01:00
parent 6b3ea4fc61
commit efdf3ab1c3
8 changed files with 26 additions and 47 deletions

View File

@ -394,9 +394,7 @@ impl ResourceDef {
pub fn set_name(&mut self, name: impl Into<String>) {
let name = name.into();
if name.is_empty() {
panic!("resource name should not be empty");
}
assert!(!name.is_empty(), "resource name should not be empty");
self.name = Some(name)
}
@ -978,9 +976,7 @@ impl ResourceDef {
let (name, pattern) = match param.find(':') {
Some(idx) => {
if tail {
panic!("custom regex is not supported for tail match");
}
assert!(!tail, "custom regex is not supported for tail match");
let (name, pattern) = param.split_at(idx);
(name, &pattern[1..])
@ -1087,12 +1083,12 @@ impl ResourceDef {
re.push_str(&escape(unprocessed));
}
if dyn_segment_count > MAX_DYNAMIC_SEGMENTS {
panic!(
"Only {} dynamic segments are allowed, provided: {}",
MAX_DYNAMIC_SEGMENTS, dyn_segment_count
);
}
assert!(
dyn_segment_count <= MAX_DYNAMIC_SEGMENTS,
"Only {} dynamic segments are allowed, provided: {}",
MAX_DYNAMIC_SEGMENTS,
dyn_segment_count
);
// Store the pattern in capture group #1 to have context info outside it
let mut re = format!("({})", re);