mirror of
https://github.com/fafhrd91/actix-web
synced 2025-07-01 16:55:08 +02:00
@ -51,16 +51,15 @@ impl Default for Compress {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, B> Transform<S> for Compress
|
||||
impl<S, B> Transform<S, ServiceRequest> for Compress
|
||||
where
|
||||
B: MessageBody,
|
||||
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
{
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse<Encoder<B>>;
|
||||
type Error = Error;
|
||||
type InitError = ();
|
||||
type Transform = CompressMiddleware<S>;
|
||||
type InitError = ();
|
||||
type Future = Ready<Result<Self::Transform, Self::InitError>>;
|
||||
|
||||
fn new_transform(&self, service: S) -> Self::Future {
|
||||
@ -76,12 +75,11 @@ pub struct CompressMiddleware<S> {
|
||||
encoding: ContentEncoding,
|
||||
}
|
||||
|
||||
impl<S, B> Service for CompressMiddleware<S>
|
||||
impl<S, B> Service<ServiceRequest> for CompressMiddleware<S>
|
||||
where
|
||||
B: MessageBody,
|
||||
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
{
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse<Encoder<B>>;
|
||||
type Error = Error;
|
||||
type Future = CompressResponse<S, B>;
|
||||
@ -115,7 +113,7 @@ where
|
||||
#[pin_project]
|
||||
pub struct CompressResponse<S, B>
|
||||
where
|
||||
S: Service,
|
||||
S: Service<ServiceRequest>,
|
||||
B: MessageBody,
|
||||
{
|
||||
#[pin]
|
||||
@ -127,7 +125,7 @@ where
|
||||
impl<S, B> Future for CompressResponse<S, B>
|
||||
where
|
||||
B: MessageBody,
|
||||
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
{
|
||||
type Output = Result<ServiceResponse<Encoder<B>>, Error>;
|
||||
|
||||
|
@ -31,19 +31,18 @@ impl<T> Condition<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, T> Transform<S> for Condition<T>
|
||||
impl<S, T, Req> Transform<S, Req> for Condition<T>
|
||||
where
|
||||
S: Service + 'static,
|
||||
T: Transform<S, Request = S::Request, Response = S::Response, Error = S::Error>,
|
||||
S: Service<Req> + 'static,
|
||||
T: Transform<S, Req, Response = S::Response, Error = S::Error>,
|
||||
T::Future: 'static,
|
||||
T::InitError: 'static,
|
||||
T::Transform: 'static,
|
||||
{
|
||||
type Request = S::Request;
|
||||
type Response = S::Response;
|
||||
type Error = S::Error;
|
||||
type InitError = T::InitError;
|
||||
type Transform = ConditionMiddleware<T::Transform, S>;
|
||||
type InitError = T::InitError;
|
||||
type Future = LocalBoxFuture<'static, Result<Self::Transform, Self::InitError>>;
|
||||
|
||||
fn new_transform(&self, service: S) -> Self::Future {
|
||||
@ -66,12 +65,11 @@ pub enum ConditionMiddleware<E, D> {
|
||||
Disable(D),
|
||||
}
|
||||
|
||||
impl<E, D> Service for ConditionMiddleware<E, D>
|
||||
impl<E, D, Req> Service<Req> for ConditionMiddleware<E, D>
|
||||
where
|
||||
E: Service,
|
||||
D: Service<Request = E::Request, Response = E::Response, Error = E::Error>,
|
||||
E: Service<Req>,
|
||||
D: Service<Req, Response = E::Response, Error = E::Error>,
|
||||
{
|
||||
type Request = E::Request;
|
||||
type Response = E::Response;
|
||||
type Error = E::Error;
|
||||
type Future = Either<E::Future, D::Future>;
|
||||
@ -84,7 +82,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn call(&mut self, req: E::Request) -> Self::Future {
|
||||
fn call(&mut self, req: Req) -> Self::Future {
|
||||
use ConditionMiddleware::*;
|
||||
match self {
|
||||
Enable(service) => Either::Left(service.call(req)),
|
||||
|
@ -93,12 +93,11 @@ impl DefaultHeaders {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, B> Transform<S> for DefaultHeaders
|
||||
impl<S, B> Transform<S, ServiceRequest> for DefaultHeaders
|
||||
where
|
||||
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S::Future: 'static,
|
||||
{
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse<B>;
|
||||
type Error = Error;
|
||||
type Transform = DefaultHeadersMiddleware<S>;
|
||||
@ -118,12 +117,11 @@ pub struct DefaultHeadersMiddleware<S> {
|
||||
inner: Rc<Inner>,
|
||||
}
|
||||
|
||||
impl<S, B> Service for DefaultHeadersMiddleware<S>
|
||||
impl<S, B> Service<ServiceRequest> for DefaultHeadersMiddleware<S>
|
||||
where
|
||||
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S::Future: 'static,
|
||||
{
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse<B>;
|
||||
type Error = Error;
|
||||
type Future = DefaultHeaderFuture<S, B>;
|
||||
@ -145,7 +143,7 @@ where
|
||||
}
|
||||
|
||||
#[pin_project::pin_project]
|
||||
pub struct DefaultHeaderFuture<S: Service, B> {
|
||||
pub struct DefaultHeaderFuture<S: Service<ServiceRequest>, B> {
|
||||
#[pin]
|
||||
fut: S::Future,
|
||||
inner: Rc<Inner>,
|
||||
@ -154,7 +152,7 @@ pub struct DefaultHeaderFuture<S: Service, B> {
|
||||
|
||||
impl<S, B> Future for DefaultHeaderFuture<S, B>
|
||||
where
|
||||
S: Service<Response = ServiceResponse<B>, Error = Error>,
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
{
|
||||
type Output = <S::Future as Future>::Output;
|
||||
|
||||
|
@ -81,17 +81,16 @@ impl<B> ErrorHandlers<B> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, B> Transform<S> for ErrorHandlers<B>
|
||||
impl<S, B> Transform<S, ServiceRequest> for ErrorHandlers<B>
|
||||
where
|
||||
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S::Future: 'static,
|
||||
B: 'static,
|
||||
{
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse<B>;
|
||||
type Error = Error;
|
||||
type InitError = ();
|
||||
type Transform = ErrorHandlersMiddleware<S, B>;
|
||||
type InitError = ();
|
||||
type Future = Ready<Result<Self::Transform, Self::InitError>>;
|
||||
|
||||
fn new_transform(&self, service: S) -> Self::Future {
|
||||
@ -108,13 +107,12 @@ pub struct ErrorHandlersMiddleware<S, B> {
|
||||
handlers: Rc<FxHashMap<StatusCode, Box<ErrorHandler<B>>>>,
|
||||
}
|
||||
|
||||
impl<S, B> Service for ErrorHandlersMiddleware<S, B>
|
||||
impl<S, B> Service<ServiceRequest> for ErrorHandlersMiddleware<S, B>
|
||||
where
|
||||
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S::Future: 'static,
|
||||
B: 'static,
|
||||
{
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse<B>;
|
||||
type Error = Error;
|
||||
type Future = LocalBoxFuture<'static, Result<Self::Response, Self::Error>>;
|
||||
|
@ -179,12 +179,11 @@ impl Default for Logger {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, B> Transform<S> for Logger
|
||||
impl<S, B> Transform<S, ServiceRequest> for Logger
|
||||
where
|
||||
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
B: MessageBody,
|
||||
{
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse<StreamLog<B>>;
|
||||
type Error = Error;
|
||||
type InitError = ();
|
||||
@ -216,12 +215,11 @@ pub struct LoggerMiddleware<S> {
|
||||
service: S,
|
||||
}
|
||||
|
||||
impl<S, B> Service for LoggerMiddleware<S>
|
||||
impl<S, B> Service<ServiceRequest> for LoggerMiddleware<S>
|
||||
where
|
||||
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
B: MessageBody,
|
||||
{
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse<StreamLog<B>>;
|
||||
type Error = Error;
|
||||
type Future = LoggerResponse<S, B>;
|
||||
@ -262,19 +260,19 @@ where
|
||||
pub struct LoggerResponse<S, B>
|
||||
where
|
||||
B: MessageBody,
|
||||
S: Service,
|
||||
S: Service<ServiceRequest>,
|
||||
{
|
||||
#[pin]
|
||||
fut: S::Future,
|
||||
time: OffsetDateTime,
|
||||
format: Option<Format>,
|
||||
_t: PhantomData<(B,)>,
|
||||
_t: PhantomData<B>,
|
||||
}
|
||||
|
||||
impl<S, B> Future for LoggerResponse<S, B>
|
||||
where
|
||||
B: MessageBody,
|
||||
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
{
|
||||
type Output = Result<ServiceResponse<StreamLog<B>>, Error>;
|
||||
|
||||
|
@ -91,16 +91,15 @@ impl NormalizePath {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, B> Transform<S> for NormalizePath
|
||||
impl<S, B> Transform<S, ServiceRequest> for NormalizePath
|
||||
where
|
||||
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S::Future: 'static,
|
||||
{
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse<B>;
|
||||
type Error = Error;
|
||||
type InitError = ();
|
||||
type Transform = NormalizePathNormalization<S>;
|
||||
type InitError = ();
|
||||
type Future = Ready<Result<Self::Transform, Self::InitError>>;
|
||||
|
||||
fn new_transform(&self, service: S) -> Self::Future {
|
||||
@ -119,12 +118,11 @@ pub struct NormalizePathNormalization<S> {
|
||||
trailing_slash_behavior: TrailingSlash,
|
||||
}
|
||||
|
||||
impl<S, B> Service for NormalizePathNormalization<S>
|
||||
impl<S, B> Service<ServiceRequest> for NormalizePathNormalization<S>
|
||||
where
|
||||
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
|
||||
S::Future: 'static,
|
||||
{
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse<B>;
|
||||
type Error = Error;
|
||||
type Future = S::Future;
|
||||
|
Reference in New Issue
Block a user