diff --git a/src/middleware/compress.rs b/src/middleware/compress.rs index d5c4082ea..86665d824 100644 --- a/src/middleware/compress.rs +++ b/src/middleware/compress.rs @@ -6,7 +6,7 @@ use std::str::FromStr; use actix_http::body::MessageBody; use actix_http::encoding::Encoder; use actix_http::http::header::{ContentEncoding, ACCEPT_ENCODING}; -use actix_http::{Response, ResponseBuilder}; +use actix_http::{Error, Response, ResponseBuilder}; use actix_service::{Service, Transform}; use futures::future::{ok, FutureResult}; use futures::{Async, Future, Poll}; @@ -71,11 +71,11 @@ impl Default for Compress { impl Transform for Compress where B: MessageBody, - S: Service>, + S: Service, Error = Error>, { type Request = ServiceRequest; type Response = ServiceResponse>; - type Error = S::Error; + type Error = Error; type InitError = (); type Transform = CompressMiddleware; type Future = FutureResult; @@ -96,11 +96,11 @@ pub struct CompressMiddleware { impl Service for CompressMiddleware where B: MessageBody, - S: Service>, + S: Service, Error = Error>, { type Request = ServiceRequest; type Response = ServiceResponse>; - type Error = S::Error; + type Error = Error; type Future = CompressResponse; fn poll_ready(&mut self) -> Poll<(), Self::Error> { @@ -141,10 +141,10 @@ where impl Future for CompressResponse where B: MessageBody, - S: Service>, + S: Service, Error = Error>, { type Item = ServiceResponse>; - type Error = S::Error; + type Error = Error; fn poll(&mut self) -> Poll { let resp = futures::try_ready!(self.fut.poll()); diff --git a/src/middleware/cors.rs b/src/middleware/cors.rs index 12cd0b83a..6e2ec9d0c 100644 --- a/src/middleware/cors.rs +++ b/src/middleware/cors.rs @@ -47,7 +47,7 @@ use futures::future::{ok, Either, Future, FutureResult}; use futures::Poll; use crate::dev::RequestHead; -use crate::error::{ResponseError, Result}; +use crate::error::{Error, ResponseError, Result}; use crate::http::header::{self, HeaderName, HeaderValue}; use crate::http::{self, HttpTryFrom, Method, StatusCode, Uri}; use crate::service::{ServiceRequest, ServiceResponse}; @@ -477,9 +477,8 @@ fn cors<'a>( impl IntoTransform for Cors where - S: Service>, + S: Service, Error = Error>, S::Future: 'static, - S::Error: 'static, B: 'static, { fn into_transform(self) -> CorsFactory { @@ -539,14 +538,13 @@ pub struct CorsFactory { impl Transform for CorsFactory where - S: Service>, + S: Service, Error = Error>, S::Future: 'static, - S::Error: 'static, B: 'static, { type Request = ServiceRequest; type Response = ServiceResponse; - type Error = S::Error; + type Error = Error; type InitError = (); type Transform = CorsMiddleware; type Future = FutureResult; @@ -680,17 +678,16 @@ impl Inner { impl Service for CorsMiddleware where - S: Service>, + S: Service, Error = Error>, S::Future: 'static, - S::Error: 'static, B: 'static, { type Request = ServiceRequest; type Response = ServiceResponse; - type Error = S::Error; + type Error = Error; type Future = Either< - FutureResult, - Either>>, + FutureResult, + Either>>, >; fn poll_ready(&mut self) -> Poll<(), Self::Error> { @@ -820,10 +817,12 @@ mod tests { impl Cors { fn finish(self, srv: S) -> CorsMiddleware where - S: Service> - + 'static, + S: Service< + Request = ServiceRequest, + Response = ServiceResponse, + Error = Error, + > + 'static, S::Future: 'static, - S::Error: 'static, B: 'static, { block_on( diff --git a/src/middleware/defaultheaders.rs b/src/middleware/defaultheaders.rs index c0e62e285..8b92b530d 100644 --- a/src/middleware/defaultheaders.rs +++ b/src/middleware/defaultheaders.rs @@ -8,6 +8,7 @@ use futures::{Future, Poll}; use crate::http::header::{HeaderName, HeaderValue, CONTENT_TYPE}; use crate::http::{HeaderMap, HttpTryFrom}; use crate::service::{ServiceRequest, ServiceResponse}; +use crate::Error; /// `Middleware` for setting default response headers. /// @@ -87,12 +88,12 @@ impl DefaultHeaders { impl Transform for DefaultHeaders where - S: Service>, + S: Service, Error = Error>, S::Future: 'static, { type Request = ServiceRequest; type Response = ServiceResponse; - type Error = S::Error; + type Error = Error; type InitError = (); type Transform = DefaultHeadersMiddleware; type Future = FutureResult; @@ -112,12 +113,12 @@ pub struct DefaultHeadersMiddleware { impl Service for DefaultHeadersMiddleware where - S: Service>, + S: Service, Error = Error>, S::Future: 'static, { type Request = ServiceRequest; type Response = ServiceResponse; - type Error = S::Error; + type Error = Error; type Future = Box>; fn poll_ready(&mut self) -> Poll<(), Self::Error> { diff --git a/src/middleware/errhandlers.rs b/src/middleware/errhandlers.rs index aa36b6a4d..acc6783f8 100644 --- a/src/middleware/errhandlers.rs +++ b/src/middleware/errhandlers.rs @@ -85,7 +85,6 @@ impl Transform for ErrorHandlers where S: Service, Error = Error>, S::Future: 'static, - S::Error: 'static, B: 'static, { type Request = ServiceRequest; @@ -113,7 +112,6 @@ impl Service for ErrorHandlersMiddleware where S: Service, Error = Error>, S::Future: 'static, - S::Error: 'static, B: 'static, { type Request = ServiceRequest; diff --git a/src/middleware/identity.rs b/src/middleware/identity.rs index 65b5309b7..82ae01542 100644 --- a/src/middleware/identity.rs +++ b/src/middleware/identity.rs @@ -203,15 +203,15 @@ impl IdentityService { impl Transform for IdentityService where - S: Service> + 'static, + S: Service, Error = Error> + + 'static, S::Future: 'static, - S::Error: 'static, T: IdentityPolicy, B: 'static, { type Request = ServiceRequest; type Response = ServiceResponse; - type Error = S::Error; + type Error = Error; type InitError = (); type Transform = IdentityServiceMiddleware; type Future = FutureResult; @@ -233,14 +233,14 @@ pub struct IdentityServiceMiddleware { impl Service for IdentityServiceMiddleware where B: 'static, - S: Service> + 'static, + S: Service, Error = Error> + + 'static, S::Future: 'static, - S::Error: 'static, T: IdentityPolicy, { type Request = ServiceRequest; type Response = ServiceResponse; - type Error = S::Error; + type Error = Error; type Future = Box>; fn poll_ready(&mut self) -> Poll<(), Self::Error> { diff --git a/src/middleware/logger.rs b/src/middleware/logger.rs index 43893bc0f..3e3fb05fa 100644 --- a/src/middleware/logger.rs +++ b/src/middleware/logger.rs @@ -116,12 +116,12 @@ impl Default for Logger { impl Transform for Logger where - S: Service>, + S: Service, Error = Error>, B: MessageBody, { type Request = ServiceRequest; type Response = ServiceResponse>; - type Error = S::Error; + type Error = Error; type InitError = (); type Transform = LoggerMiddleware; type Future = FutureResult; @@ -142,12 +142,12 @@ pub struct LoggerMiddleware { impl Service for LoggerMiddleware where - S: Service>, + S: Service, Error = Error>, B: MessageBody, { type Request = ServiceRequest; type Response = ServiceResponse>; - type Error = S::Error; + type Error = Error; type Future = LoggerResponse; fn poll_ready(&mut self) -> Poll<(), Self::Error> { @@ -194,10 +194,10 @@ where impl Future for LoggerResponse where B: MessageBody, - S: Service>, + S: Service, Error = Error>, { type Item = ServiceResponse>; - type Error = S::Error; + type Error = Error; fn poll(&mut self) -> Poll { let res = futures::try_ready!(self.fut.poll()); diff --git a/src/middleware/normalize.rs b/src/middleware/normalize.rs index 060331a6b..7289e8d97 100644 --- a/src/middleware/normalize.rs +++ b/src/middleware/normalize.rs @@ -5,6 +5,7 @@ use futures::future::{self, FutureResult}; use regex::Regex; use crate::service::{ServiceRequest, ServiceResponse}; +use crate::Error; #[derive(Default, Clone, Copy)] /// `Middleware` to normalize request's URI in place @@ -16,11 +17,11 @@ pub struct NormalizePath; impl Transform for NormalizePath where - S: Service, + S: Service, { type Request = ServiceRequest; type Response = ServiceResponse; - type Error = S::Error; + type Error = Error; type InitError = (); type Transform = NormalizePathNormalization; type Future = FutureResult; @@ -40,11 +41,11 @@ pub struct NormalizePathNormalization { impl Service for NormalizePathNormalization where - S: Service, + S: Service, { type Request = ServiceRequest; type Response = ServiceResponse; - type Error = S::Error; + type Error = Error; type Future = S::Future; fn poll_ready(&mut self) -> futures::Poll<(), Self::Error> { diff --git a/src/scope.rs b/src/scope.rs index 81bf84d23..d048d1437 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -247,7 +247,7 @@ where /// Registers middleware, in the form of a closure, that runs during inbound /// processing in the request lifecycle (request -> response), modifying - /// request as necessary, across all requests managed by the *Scope*. + /// request as necessary, across all requests managed by the *Scope*. /// Scope-level middleware is more limited in what it can modify, relative /// to Route or Application level middleware, in that Scope-level middleware /// can not modify ServiceResponse.