use crate::contracts::pipeline::Pipeable;
use crate::http::{Request, Response};
use crate::pipeline;
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
pub type BoxFuture<'a, T = Response> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
pub type HandlerFn = Arc<dyn Fn(Request) -> BoxFuture<'static, Response> + Send + Sync + 'static>;
pub type Next = pipeline::Next<Request, Response>;
pub trait Middleware: Send + Sync + 'static {
fn handle<'a>(&'a self, request: Request, next: Next) -> BoxFuture<'a, Response>;
}
impl Pipeable<Request, Response> for dyn Middleware {
fn handle<'a>(&'a self, passable: Request, next: Next) -> BoxFuture<'a, Response> {
Middleware::handle(self, passable, next)
}
}