#[macro_export]
macro_rules! routes {
($route:expr $(,)?) => {
$crate::Router::new($route)
};
($route:expr, $($rest:expr),+ $(,)?) => {
$crate::routes!($($rest),+).route($route)
}
}
#[cfg(test)]
macro_rules! param {
($Type:ident, $method:ident, $path:expr) => {
struct $Type;
impl<T> $crate::param::Param<::http::request::Request<T>> for $Type {
#[inline]
fn from_request(
req: &::http::request::Request<T>,
) -> Result<Self, $crate::error::Error> {
if req.method() != &::http::Method::$method {
return Err($crate::error::Error::Method);
}
if req.uri().path() != $path {
return Err($crate::error::Error::Path);
}
Ok($Type)
}
}
};
($Type:ident, $method:ident) => {
struct $Type;
impl<T> $crate::param::Param<::http::request::Request<T>> for $Type {
#[inline]
fn from_request(
req: &::http::request::Request<T>,
) -> Result<Self, $crate::error::Error> {
if req.uri().path() != $path {
return Err($crate::error::Error::Path);
}
Ok($Type)
}
}
};
($Type:ident, $path:expr) => {
struct $Type;
impl<T> $crate::param::Param<::http::request::Request<T>> for $Type {
#[inline]
fn from_request(
req: &::http::request::Request<T>,
) -> Result<Self, $crate::error::Error> {
if req.uri().path() != $path {
return Err($crate::error::Error::Path);
}
Ok($Type)
}
}
};
}
#[cfg(test)]
pub(crate) use param;