mirror of
https://github.com/zerotier/ratpack.git
synced 2026-05-22 16:27:23 -07:00
@@ -6,6 +6,7 @@ use tokio::net::TcpListener;
|
||||
|
||||
use crate::{handler::Handler, router::Router, Error, ServerError};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct App {
|
||||
router: Router,
|
||||
}
|
||||
|
||||
+3
-3
@@ -6,13 +6,13 @@ use async_recursion::async_recursion;
|
||||
use http::{Request, Response};
|
||||
use hyper::Body;
|
||||
|
||||
pub(crate) type Params = BTreeMap<String, String>;
|
||||
pub type Params = BTreeMap<String, String>;
|
||||
|
||||
pub type HandlerFunc = fn(
|
||||
req: Request<Body>,
|
||||
response: Option<Response<Body>>,
|
||||
params: Params,
|
||||
) -> PinBox<dyn Future<Output = HTTPResult> + Send + 'static>;
|
||||
) -> PinBox<dyn Future<Output = HTTPResult> + 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<Handler>) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -9,6 +9,7 @@ use std::pin::Pin;
|
||||
|
||||
pub(crate) type PinBox<F> = Pin<Box<F>>;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ServerError(String);
|
||||
|
||||
impl<T> From<T> for ServerError
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
macro_rules! compose_handler {
|
||||
($( $x:path ),*) => {
|
||||
{
|
||||
use crate::handler::{HandlerFunc, Handler};
|
||||
use $crate::handler::{HandlerFunc, Handler};
|
||||
{
|
||||
let mut funcs: Vec<HandlerFunc> = Vec::new();
|
||||
|
||||
|
||||
@@ -67,7 +67,6 @@ impl Router {
|
||||
self.clone()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) async fn dispatch(&self, req: Request<Body>) -> Result<Response<Body>, Error> {
|
||||
let path = req.uri().path().to_string();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user