From d571ee5abb921d15114e91158f3a48b2b6621285 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Thu, 25 Apr 2019 11:19:21 -0700 Subject: [PATCH] explicit Error for middlewares --- middleware/src/redirect.rs | 10 +++++----- middleware/src/simple.rs | 12 +++++------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/middleware/src/redirect.rs b/middleware/src/redirect.rs index 670caa4..f5c0e61 100644 --- a/middleware/src/redirect.rs +++ b/middleware/src/redirect.rs @@ -1,6 +1,6 @@ use actix_service::{Service, Transform}; use actix_web::dev::{ServiceRequest, ServiceResponse}; -use actix_web::{http, HttpResponse}; +use actix_web::{http, Error, HttpResponse}; use futures::future::{ok, Either, FutureResult}; use futures::Poll; @@ -8,12 +8,12 @@ pub struct CheckLogin; impl Transform for CheckLogin 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 = CheckLoginMiddleware; type Future = FutureResult; @@ -28,12 +28,12 @@ pub struct CheckLoginMiddleware { impl Service for CheckLoginMiddleware 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 = Either>; fn poll_ready(&mut self) -> Poll<(), Self::Error> { diff --git a/middleware/src/simple.rs b/middleware/src/simple.rs index 277257e..faf04cf 100644 --- a/middleware/src/simple.rs +++ b/middleware/src/simple.rs @@ -1,5 +1,5 @@ use actix_service::{Service, Transform}; -use actix_web::dev::{ServiceRequest, ServiceResponse}; +use actix_web::{dev::ServiceRequest, dev::ServiceResponse, Error}; use futures::future::{ok, FutureResult}; use futures::{Future, Poll}; @@ -14,14 +14,13 @@ pub struct SayHi; // `B` - type of response's body impl Transform for SayHi 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 = SayHiMiddleware; type Future = FutureResult; @@ -37,14 +36,13 @@ pub struct SayHiMiddleware { impl Service for SayHiMiddleware 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 = Box>; fn poll_ready(&mut self) -> Poll<(), Self::Error> {