1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#[macro_export]
macro_rules! route {
    ($func_name:ident) => (
        pub fn $func_name<H>(&mut self, pattern: &str, handle: H) -> &mut Route
            where H: Fn(&mut Context) + Send + Sync + 'static
        {
            self.add(&stringify!($func_name).to_uppercase(), pattern, handle)
        }
    )
}

#[macro_export]
macro_rules! middleware {
    ($func_name:ident) => (
        pub fn $func_name<H>(&mut self, handle: H) -> &mut Self
            where H: Fn(&mut Context) + Send + Sync + 'static
        {
            self.$func_name.push(Middleware {
                inner: Box::new(handle),
            });

            self
        }
    )
}