use std::marker::PhantomData; use actix_service::{NewTransform, Service, Transform}; use futures::future::{ok, FutureResult}; #[cfg(any(feature = "brotli", feature = "flate2"))] mod compress; #[cfg(any(feature = "brotli", feature = "flate2"))] pub use self::compress::Compress; mod defaultheaders; pub use self::defaultheaders::DefaultHeaders; /// Helper for middleware service factory pub struct MiddlewareFactory where T: Transform + Clone, S: Service, { tr: T, _t: PhantomData, } impl MiddlewareFactory where T: Transform + Clone, S: Service, { pub fn new(tr: T) -> Self { MiddlewareFactory { tr, _t: PhantomData, } } } impl NewTransform for MiddlewareFactory where T: Transform + Clone, S: Service, { type Request = T::Request; type Response = T::Response; type Error = T::Error; type Transform = T; type InitError = (); type Future = FutureResult; fn new_transform(&self, _: &C) -> Self::Future { ok(self.tr.clone()) } }