diff --git a/src/app.rs b/src/app.rs index b2e6079..ea26827 100644 --- a/src/app.rs +++ b/src/app.rs @@ -6,6 +6,7 @@ use tokio::net::TcpListener; use crate::{handler::Handler, router::Router, Error, ServerError}; +#[derive(Clone)] pub struct App { router: Router, } diff --git a/src/handler.rs b/src/handler.rs index 8217ed5..425e64c 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -6,13 +6,13 @@ use async_recursion::async_recursion; use http::{Request, Response}; use hyper::Body; -pub(crate) type Params = BTreeMap; +pub type Params = BTreeMap; pub type HandlerFunc = fn( req: Request, response: Option>, params: Params, -) -> PinBox + Send + 'static>; +) -> PinBox + Send>; #[derive(Clone)] pub struct Handler { @@ -22,7 +22,7 @@ pub struct Handler { impl Handler where - Self: Send + 'static, + Self: Send, { pub fn new(handler: HandlerFunc, next: Option) -> Self { Self { diff --git a/src/lib.rs b/src/lib.rs index 0099800..a48f3e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,7 @@ use std::pin::Pin; pub(crate) type PinBox = Pin>; +#[derive(Debug, Clone)] pub struct ServerError(String); impl From for ServerError diff --git a/src/macros.rs b/src/macros.rs index 76060a5..af2e329 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -2,7 +2,7 @@ macro_rules! compose_handler { ($( $x:path ),*) => { { - use crate::handler::{HandlerFunc, Handler}; + use $crate::handler::{HandlerFunc, Handler}; { let mut funcs: Vec = Vec::new(); diff --git a/src/router.rs b/src/router.rs index 4fe4f6c..5c3ec9a 100644 --- a/src/router.rs +++ b/src/router.rs @@ -67,7 +67,6 @@ impl Router { self.clone() } - #[allow(dead_code)] pub(crate) async fn dispatch(&self, req: Request) -> Result, Error> { let path = req.uri().path().to_string();