Skip to content

Commit 628b6d1

Browse files
committed
Store the 'static Handler
1 parent bdb3e7e commit 628b6d1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/conduit-router.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use router::{Router, Match};
1212
use conduit::{Method, Handler, Request, Response};
1313

1414
pub struct RouteBuilder {
15-
routers: HashMap<Method, Router<Box<Handler>>>
15+
routers: HashMap<Method, Router<Box<Handler + 'static>>>
1616
}
1717

1818
macro_rules! method_map(
@@ -30,7 +30,8 @@ impl RouteBuilder {
3030
RouteBuilder { routers: HashMap::new() }
3131
}
3232

33-
pub fn recognize<'a>(&'a self, method: &Method, path: &str) -> Result<Match<&'a Box<Handler>>, String> {
33+
pub fn recognize<'a>(&'a self, method: &Method,
34+
path: &str) -> Result<Match<&'a Box<Handler + 'static>>, String> {
3435
match self.routers.find(method) {
3536
None => Err(format!("No router found for {}", method)),
3637
Some(router) => router.recognize(path)
@@ -43,7 +44,7 @@ impl RouteBuilder {
4344
{
4445
{
4546
let router = self.routers.find_or_insert_with(method, |_| Router::new());
46-
router.add(pattern, box handler as Box<Handler>);
47+
router.add(pattern, box handler as Box<Handler + 'static>);
4748
}
4849
self
4950
}

0 commit comments

Comments
 (0)