Skip to content

Commit 4abb1b1

Browse files
committed
Don't fail for an unrecognized path
1 parent 8cb0bc2 commit 4abb1b1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/conduit-router.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ impl conduit::Handler for RouteBuilder {
9494
let method = request.method();
9595
let path = request.path();
9696

97-
self.recognize(&method, path).unwrap()
97+
match self.recognize(&method, path) {
98+
Ok(m) => m,
99+
Err(e) => return Err(box e as Box<Show>)
100+
}
98101
};
99102

100103
{
@@ -191,6 +194,9 @@ mod tests {
191194

192195
assert_eq!(res.status, (200, "OK"));
193196
assert_eq!(res.body.read_to_str().unwrap(), "10, Post".to_str());
197+
198+
let mut req = RequestSentinel::new(conduit::Post, "/nonexistent");
199+
router.call(&mut req).err().expect("No response");
194200
}
195201

196202
fn handler1(req: &mut conduit::Request) -> Result<conduit::Response, ()> {

0 commit comments

Comments
 (0)