1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-26 18:37:41 +02:00

migrate to actix-web beta 14 (#209)

This commit is contained in:
Rob Ede
2021-12-11 16:05:21 +00:00
committed by GitHub
parent 700d90b68b
commit 74ec115161
27 changed files with 134 additions and 128 deletions

View File

@ -11,7 +11,7 @@ use std::{
};
use actix_web::{
body::{AnyBody, MessageBody},
body::{EitherBody, MessageBody},
dev::{Service, ServiceRequest, ServiceResponse, Transform},
Error,
};
@ -127,7 +127,7 @@ where
B: MessageBody + 'static,
B::Error: StdError,
{
type Response = ServiceResponse;
type Response = ServiceResponse<EitherBody<B>>;
type Error = Error;
type Transform = AuthenticationMiddleware<S, F, T>;
type InitError = ();
@ -162,9 +162,9 @@ where
B: MessageBody + 'static,
B::Error: StdError,
{
type Response = ServiceResponse;
type Response = ServiceResponse<EitherBody<B>>;
type Error = S::Error;
type Future = LocalBoxFuture<'static, Result<ServiceResponse, Error>>;
type Future = LocalBoxFuture<'static, Result<Self::Response, Self::Error>>;
actix_service::forward_ready!(service);
@ -177,7 +177,7 @@ where
let (req, credentials) = match Extract::<T>::new(req).await {
Ok(req) => req,
Err((err, req)) => {
return Ok(req.error_response(err));
return Ok(req.error_response(err).map_into_right_body());
}
};
@ -185,10 +185,7 @@ where
// middleware to do their thing (eg. cors adding headers)
let req = process_fn(req, credentials).await?;
service
.call(req)
.await
.map(|res| res.map_body(|_, body| AnyBody::new_boxed(body)))
service.call(req).await.map(|res| res.map_into_left_body())
}
.boxed_local()
}