Struct actix_cors::Cors [−][src]
pub struct Cors { /* fields omitted */ }
Expand description
Builder for CORS middleware.
+Struct actix_cors::Cors [−][src]
pub struct Cors { /* fields omitted */ }
Expand description
Builder for CORS middleware.
To construct a CORS middleware, call Cors::default()
to create a blank, restrictive builder.
Then use any of the builder methods to customize CORS behavior.
The alternative Cors::permissive()
constructor is available for local development, allowing
@@ -21,12 +21,12 @@ server will fail to start up or serve requests.
Implementations
A very permissive set of default for quick development. Not recommended for production use.
+Implementations
A very permissive set of default for quick development. Not recommended for production use.
All origins, methods, request headers and exposed headers allowed. Credentials supported. Max age 1 hour. Does not send wildcard.
-Resets allowed origin list to a state where any origin is accepted.
+Resets allowed origin list to a state where any origin is accepted.
See Cors::allowed_origin
for more info on allowed origins.
Add an origin that is allowed to make requests.
+Add an origin that is allowed to make requests.
By default, requests from all origins are accepted by CORS logic. This method allows to
specify a finite set of origins to verify the value of the Origin
request header.
These are origin-or-null
types in the Fetch Standard.
*
). Cors::send_wildcard
should be used instead.pub fn allowed_origin_fn<F>(self, f: F) -> Cors where
F: Fn(&HeaderValue, &RequestHead) -> bool + 'static,
pub fn allowed_origin_fn<F>(self, f: F) -> Cors where
F: Fn(&HeaderValue, &RequestHead) -> bool + 'static,
Determinate allowed origins by processing requests which didn’t match any origins specified +
pub fn allowed_origin_fn<F>(self, f: F) -> Cors where
F: Fn(&HeaderValue, &RequestHead) -> bool + 'static,
pub fn allowed_origin_fn<F>(self, f: F) -> Cors where
F: Fn(&HeaderValue, &RequestHead) -> bool + 'static,
Determinate allowed origins by processing requests which didn’t match any origins specified
in the allowed_origin
.
The function will receive two parameters, the Origin header value, and the RequestHead
of
each request, which can be used to determine whether to allow the request or not.
If the function returns true
, the client’s Origin
request header will be echoed back
into the Access-Control-Allow-Origin
response header.
Resets allowed methods list to all methods.
+Resets allowed methods list to all methods.
See Cors::allowed_methods
for more info on allowed methods.
Set a list of methods which allowed origins can perform.
+Set a list of methods which allowed origins can perform.
These will be sent in the Access-Control-Allow-Methods
response header as specified in
the Fetch Standard CORS protocol.
Defaults to [GET, HEAD, POST, OPTIONS, PUT, PATCH, DELETE]
Resets allowed request header list to a state where any header is accepted.
+Resets allowed request header list to a state where any header is accepted.
See Cors::allowed_headers
for more info on allowed request headers.
pub fn allowed_header<H>(self, header: H) -> Cors where
H: TryInto<HeaderName>,
<H as TryInto<HeaderName>>::Error: Into<HttpError>,
pub fn allowed_header<H>(self, header: H) -> Cors where
H: TryInto<HeaderName>,
<H as TryInto<HeaderName>>::Error: Into<HttpError>,
Add an allowed request header.
+pub fn allowed_header<H>(self, header: H) -> Cors where
H: TryInto<HeaderName>,
<H as TryInto<HeaderName>>::Error: Into<HttpError>,
pub fn allowed_header<H>(self, header: H) -> Cors where
H: TryInto<HeaderName>,
<H as TryInto<HeaderName>>::Error: Into<HttpError>,
Add an allowed request header.
See Cors::allowed_headers
for more info on allowed request headers.
pub fn allowed_headers<U, H>(self, headers: U) -> Cors where
U: IntoIterator<Item = H>,
H: TryInto<HeaderName>,
<H as TryInto<HeaderName>>::Error: Into<HttpError>,
pub fn allowed_headers<U, H>(self, headers: U) -> Cors where
U: IntoIterator<Item = H>,
H: TryInto<HeaderName>,
<H as TryInto<HeaderName>>::Error: Into<HttpError>,
Set a list of request header field names which can be used when this resource is accessed by +
pub fn allowed_headers<U, H>(self, headers: U) -> Cors where
U: IntoIterator<Item = H>,
H: TryInto<HeaderName>,
<H as TryInto<HeaderName>>::Error: Into<HttpError>,
pub fn allowed_headers<U, H>(self, headers: U) -> Cors where
U: IntoIterator<Item = H>,
H: TryInto<HeaderName>,
<H as TryInto<HeaderName>>::Error: Into<HttpError>,
Set a list of request header field names which can be used when this resource is accessed by allowed origins.
If All
is set, whatever is requested by the client in Access-Control-Request-Headers
will be echoed back in the Access-Control-Allow-Headers
header as specified in
the Fetch Standard CORS protocol.
Defaults to All
.
Resets exposed response header list to a state where any header is accepted.
+Resets exposed response header list to a state where any header is accepted.
See Cors::expose_headers
for more info on exposed response headers.
pub fn expose_headers<U, H>(self, headers: U) -> Cors where
U: IntoIterator<Item = H>,
H: TryInto<HeaderName>,
<H as TryInto<HeaderName>>::Error: Into<HttpError>,
pub fn expose_headers<U, H>(self, headers: U) -> Cors where
U: IntoIterator<Item = H>,
H: TryInto<HeaderName>,
<H as TryInto<HeaderName>>::Error: Into<HttpError>,
Set a list of headers which are safe to expose to the API of a CORS API specification. +
pub fn expose_headers<U, H>(self, headers: U) -> Cors where
U: IntoIterator<Item = H>,
H: TryInto<HeaderName>,
<H as TryInto<HeaderName>>::Error: Into<HttpError>,
pub fn expose_headers<U, H>(self, headers: U) -> Cors where
U: IntoIterator<Item = H>,
H: TryInto<HeaderName>,
<H as TryInto<HeaderName>>::Error: Into<HttpError>,
Set a list of headers which are safe to expose to the API of a CORS API specification.
This corresponds to the Access-Control-Expose-Headers
response header as specified in
the Fetch Standard CORS protocol.
This defaults to an empty set.
-Set a maximum time (in seconds) for which this CORS request maybe cached. +
Set a maximum time (in seconds) for which this CORS request maybe cached.
This value is set as the Access-Control-Max-Age
header as specified in
the Fetch Standard CORS protocol.
Pass a number (of seconds) or use None to disable sending max age header.
-Set to use wildcard origins.
+Set to use wildcard origins.
If send wildcard is set and the allowed_origins
parameter is All
, a wildcard
Access-Control-Allow-Origin
response header is sent, rather than the request’s
Origin
header.
allow_credentials
set to true
. Depending on the mode of usage, this will either result
in an CorsError::CredentialsWithWildcardOrigin
error during actix launch or runtime.
Defaults to false
.
Allows users to make authenticated requests
+Allows users to make authenticated requests
If true, injects the Access-Control-Allow-Credentials
header in responses. This allows
cookies and credentials to be submitted across domains as specified in
the Fetch Standard CORS protocol.
Defaults to false
.
A server initialization error will occur if credentials are allowed, but the Origin is set
to send wildcards (*
); this is not allowed by the CORS protocol.
Disable Vary
header support.
Disable Vary
header support.
When enabled the header Vary: Origin
will be returned as per the Fetch Standard
implementation guidelines.
Setting this header when the Access-Control-Allow-Origin
is dynamically generated
(eg. when there is more than one allowed origin, and an Origin other than ‘*’ is returned)
informs CDNs and other caches that the CORS headers are dynamic, and cannot be cached.
By default, Vary
header support is enabled.
Disable support for preflight requests.
+Disable support for preflight requests.
When enabled CORS middleware automatically handles OPTIONS
requests.
This is useful for application level middleware.
By default preflight support is enabled.
-Trait Implementations
Trait Implementations
type Response = ServiceResponse
type Response = ServiceResponse
Responses produced by the service.
+type Response = ServiceResponse<EitherBody<B>>
type Response = ServiceResponse<EitherBody<B>>
Responses produced by the service.
type Error = Error
type Error = Error
Errors produced by the service.
type Transform = CorsMiddleware<S>
type Transform = CorsMiddleware<S>
The TransformService
value created by this factory
type Future = Ready<Result<Self::Transform, Self::InitError>>
type Future = Ready<Result<Self::Transform, Self::InitError>>
The future response value.
-Creates and returns a new Transform component, asynchronously
+Creates and returns a new Transform component, asynchronously
Auto Trait Implementations
impl !RefUnwindSafe for Cors
impl !UnwindSafe for Cors
Blanket Implementations
Mutably borrows from an owned value. Read more
diff --git a/actix_identity/index.html b/actix_identity/index.html index 0020e26c7..d7a25d1bd 100644 --- a/actix_identity/index.html +++ b/actix_identity/index.html @@ -1,5 +1,5 @@Crate actix_identity[−][src]
Expand description
Opinionated request identity service for Actix Web apps.
+Crate actix_identity[−][src]
Expand description
Opinionated request identity service for Actix Web apps.
IdentityService
middleware can be used with different policies types to store
identity information.
A cookie based policy is provided. CookieIdentityPolicy
uses cookies as identity storage.
Implementations
Trait Implementations
impl<S, T, B> Transform<S, ServiceRequest> for IdentityService<T> where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error> + 'static,
S::Future: 'static,
T: IdentityPolicy,
B: MessageBody + 'static,
B::Error: StdError,
impl<S, T, B> Transform<S, ServiceRequest> for IdentityService<T> where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error> + 'static,
S::Future: 'static,
T: IdentityPolicy,
B: MessageBody + 'static,
B::Error: StdError,
type Response = ServiceResponse
type Response = ServiceResponse
Responses produced by the service.
+Trait Implementations
impl<S, T, B> Transform<S, ServiceRequest> for IdentityService<T> where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error> + 'static,
S::Future: 'static,
T: IdentityPolicy,
B: MessageBody + 'static,
B::Error: StdError,
impl<S, T, B> Transform<S, ServiceRequest> for IdentityService<T> where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error> + 'static,
S::Future: 'static,
T: IdentityPolicy,
B: MessageBody + 'static,
B::Error: StdError,
type Response = ServiceResponse<EitherBody<B>>
type Response = ServiceResponse<EitherBody<B>>
Responses produced by the service.
type Error = Error
type Error = Error
Errors produced by the service.
type Transform = IdentityServiceMiddleware<S, T>
type Transform = IdentityServiceMiddleware<S, T>
The TransformService
value created by this factory
Enum actix_protobuf::ProtoBufPayloadError [−][src]
pub enum ProtoBufPayloadError {
+ Enum actix_protobuf::ProtoBufPayloadError [−][src]
pub enum ProtoBufPayloadError {
Overflow,
ContentType,
Serialize(ProtoBufEncodeError),
@@ -10,11 +10,11 @@
Serialize(ProtoBufEncodeError)
Tuple Fields
Serialize error
Deserialize(ProtoBufDecodeError)
Tuple Fields
Deserialize error
Payload(PayloadError)
Payload error
-Trait Implementations
Performs the conversion.
-
Performs the conversion.
-
Creates full response for error. Read more
+Trait Implementations
Performs the conversion.
+
Performs the conversion.
+
Creates full response for error. Read more
fn status_code(&self) -> StatusCode
Returns appropriate status code for error. Read more
Auto Trait Implementations
impl !RefUnwindSafe for ProtoBufPayloadError
impl Send for ProtoBufPayloadError
impl Sync for ProtoBufPayloadError
impl Unpin for ProtoBufPayloadError
impl !UnwindSafe for ProtoBufPayloadError
Blanket Implementations
Immutably borrows from an owned value. Read more
diff --git a/actix_protobuf/index.html b/actix_protobuf/index.html
index 385067fca..8e41efa0b 100644
--- a/actix_protobuf/index.html
+++ b/actix_protobuf/index.html
@@ -1,5 +1,5 @@
actix_protobuf - Rust
- Crate actix_protobuf[−][src]
Structs
+
diff --git a/actix_protobuf/struct.ProtoBuf.html b/actix_protobuf/struct.ProtoBuf.html
index dd3fbe6f4..f8cb57867 100644
--- a/actix_protobuf/struct.ProtoBuf.html
+++ b/actix_protobuf/struct.ProtoBuf.html
@@ -1,14 +1,14 @@
ProtoBuf in actix_protobuf - Rust
- Struct actix_protobuf::ProtoBuf [−][src]
pub struct ProtoBuf<T: Message>(pub T);
Tuple Fields
0: T
Trait Implementations
type Error = Error
The associated error which can be returned.
+ Struct actix_protobuf::ProtoBuf [−][src]
pub struct ProtoBuf<T: Message>(pub T);
Tuple Fields
0: T
Trait Implementations
type Error = Error
The associated error which can be returned.
Create a Self from request parts asynchronously.
+
Create a Self from request parts asynchronously.
Convert self to HttpResponse
.
+
type Body = BoxBody
Convert self to HttpResponse
.
fn with_status(self, status: StatusCode) -> CustomResponder<Self>
Override a status code for a Responder. Read more
fn with_header<H>(self, header: H) -> CustomResponder<Self> where
H: IntoHeaderPair,
Insert header to the final response. Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for ProtoBuf<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for ProtoBuf<T> where
T: UnwindSafe,
Blanket Implementations
Gets the TypeId
of self
. Read more
diff --git a/actix_protobuf/struct.ProtoBufConfig.html b/actix_protobuf/struct.ProtoBufConfig.html
index 11a5af84c..d52bfd742 100644
--- a/actix_protobuf/struct.ProtoBufConfig.html
+++ b/actix_protobuf/struct.ProtoBufConfig.html
@@ -1,6 +1,6 @@
ProtoBufConfig in actix_protobuf - Rust
- Struct actix_protobuf::ProtoBufConfig [−][src]
pub struct ProtoBufConfig { /* fields omitted */ }
Implementations
Trait Implementations
Returns the “default value” for a type. Read more
+ Struct actix_protobuf::ProtoBufConfig [−][src]
pub struct ProtoBufConfig { /* fields omitted */ }
Implementations
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for ProtoBufConfig
impl Send for ProtoBufConfig
impl Sync for ProtoBufConfig
impl Unpin for ProtoBufConfig
impl UnwindSafe for ProtoBufConfig
Blanket Implementations
Mutably borrows from an owned value. Read more
diff --git a/actix_protobuf/struct.ProtoBufMessage.html b/actix_protobuf/struct.ProtoBufMessage.html
index 199103cf1..6b0723e07 100644
--- a/actix_protobuf/struct.ProtoBufMessage.html
+++ b/actix_protobuf/struct.ProtoBufMessage.html
@@ -1,8 +1,8 @@
ProtoBufMessage in actix_protobuf - Rust
- Struct actix_protobuf::ProtoBufMessage [−][src]
Implementations
Trait Implementations
type Output = Result<T, ProtoBufPayloadError>
The type of value produced on completion.
-
Attempt to resolve the future to a final value, registering
+
Struct actix_protobuf::ProtoBufMessage [−][src]
Implementations
Trait Implementations
type Output = Result<T, ProtoBufPayloadError>
The type of value produced on completion.
+Auto Trait Implementations
impl<T> !RefUnwindSafe for ProtoBufMessage<T>
impl<T> !Send for ProtoBufMessage<T>
impl<T> !Sync for ProtoBufMessage<T>
impl<T> Unpin for ProtoBufMessage<T>
impl<T> !UnwindSafe for ProtoBufMessage<T>
Blanket Implementations
Immutably borrows from an owned value. Read more
diff --git a/actix_protobuf/trait.ProtoBufResponseBuilder.html b/actix_protobuf/trait.ProtoBufResponseBuilder.html
index 93e89d88a..fd7e80fb1 100644
--- a/actix_protobuf/trait.ProtoBufResponseBuilder.html
+++ b/actix_protobuf/trait.ProtoBufResponseBuilder.html
@@ -1,5 +1,5 @@
ProtoBufResponseBuilder in actix_protobuf - Rust
- Trait actix_protobuf::ProtoBufResponseBuilder [−][src]
pub trait ProtoBufResponseBuilder {
+ Trait actix_protobuf::ProtoBufResponseBuilder [−][src]
pub trait ProtoBufResponseBuilder {
fn protobuf<T: Message>(&mut self, value: T) -> Result<HttpResponse, Error>;
-}
Required methods
Implementations on Foreign Types
Implementors
+}
Required methods
Implementations on Foreign Types
Implementors
\ No newline at end of file
diff --git a/actix_redis/enum.Error.html b/actix_redis/enum.Error.html
index 347208643..035e2061f 100644
--- a/actix_redis/enum.Error.html
+++ b/actix_redis/enum.Error.html
@@ -14,7 +14,7 @@
fn status_code(&self) -> StatusCode
Returns appropriate status code for error. Read more
-fn error_response(&self) -> HttpResponse<AnyBody<BoxBody>>
Creates full response for error. Read more
+fn error_response(&self) -> HttpResponse<BoxBody>
Creates full response for error. Read more
Auto Trait Implementations
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
Blanket Implementations
Mutably borrows from an owned value. Read more
diff --git a/actix_session/enum.SessionStatus.html b/actix_session/enum.SessionStatus.html
index 991d046e7..1b49b4b78 100644
--- a/actix_session/enum.SessionStatus.html
+++ b/actix_session/enum.SessionStatus.html
@@ -1,5 +1,5 @@
SessionStatus in actix_session - Rust
- Enum actix_session::SessionStatus [−][src]
pub enum SessionStatus {
+ Enum actix_session::SessionStatus [−][src]
pub enum SessionStatus {
Changed,
Purged,
Renewed,
@@ -15,14 +15,14 @@ be notified of the refresh.
Unchanged
Session is unchanged from when last seen (if exists).
This state also captures new (previously unissued) sessions such as a user’s first
site visit.
-Trait Implementations
Returns a copy of the value. Read more
+Trait Implementations
Returns the “default value” for a type. Read more
-
This method tests for self
and other
values to be equal, and is used
+
Returns the “default value” for a type. Read more
+
Auto Trait Implementations
impl RefUnwindSafe for SessionStatus
impl Send for SessionStatus
impl Sync for SessionStatus
impl Unpin for SessionStatus
impl UnwindSafe for SessionStatus
Blanket Implementations
Auto Trait Implementations
impl RefUnwindSafe for SessionStatus
impl Send for SessionStatus
impl Sync for SessionStatus
impl Unpin for SessionStatus
impl UnwindSafe for SessionStatus
Blanket Implementations
Mutably borrows from an owned value. Read more
Performs the conversion.
diff --git a/actix_session/index.html b/actix_session/index.html
index 2ceb3af79..80cb2faa2 100644
--- a/actix_session/index.html
+++ b/actix_session/index.html
@@ -1,5 +1,5 @@
actix_session - Rust
- Crate actix_session[−][src]
Expand description
Sessions for Actix Web.
+ Crate actix_session[−][src]
Expand description
Sessions for Actix Web.
Provides a general solution for session management. Session middleware could provide different
implementations which could be accessed via general session API.
This crate provides a general solution for session management and includes a cookie backend.
diff --git a/actix_session/struct.CookieSession.html b/actix_session/struct.CookieSession.html
index 15f841344..7927f0a75 100644
--- a/actix_session/struct.CookieSession.html
+++ b/actix_session/struct.CookieSession.html
@@ -50,7 +50,7 @@ connection is secure - i.e. https
Sets the expires
field in the session cookie being built.
Trait Implementations
impl<S, B> Transform<S, ServiceRequest> for CookieSession where
S: Service<ServiceRequest, Response = ServiceResponse<B>>,
S::Future: 'static,
S::Error: 'static,
B: MessageBody + 'static,
B::Error: StdError,
type Response = ServiceResponse
Responses produced by the service.
+impl<S, B> Transform<S, ServiceRequest> for CookieSession where
S: Service<ServiceRequest, Response = ServiceResponse<B>>,
S::Future: 'static,
S::Error: 'static,
B: MessageBody + 'static,
B::Error: StdError,
type Response = ServiceResponse<EitherBody<B>>
Responses produced by the service.
type Error = S::Error
Errors produced by the service.
type Transform = CookieSessionMiddleware<S>
The TransformService
value created by this factory
diff --git a/actix_session/struct.Session.html b/actix_session/struct.Session.html
index 2aa4cc174..67b95317e 100644
--- a/actix_session/struct.Session.html
+++ b/actix_session/struct.Session.html
@@ -16,21 +16,21 @@ implemented for HttpRequest
, ServiceRequest
, and Ok("Welcome!")
}
-Implementations
Get a value
from the session.
-
Get all raw key-value data from the session.
+Implementations
Get a value
from the session.
+
Get all raw key-value data from the session.
Note that values are JSON encoded.
-
Inserts a key-value pair into the session.
+
Inserts a key-value pair into the session.
Any serializable value can be used and will be encoded as JSON in session data, hence why
only a reference to the value is taken.
-
Remove value from the session.
If present, the JSON encoded value is returned.
-
Remove value from the session and deserialize.
+
Remove value from the session and deserialize.
Returns None if key was not present in session. Returns T if deserialization succeeds,
otherwise returns un-deserialized JSON string.
-pub fn set_session(
req: &mut ServiceRequest,
data: impl IntoIterator<Item = (String, String)>
)
Adds the given key-value pairs to the session on the request.
+pub fn set_session(
req: &mut ServiceRequest,
data: impl IntoIterator<Item = (String, String)>
)
Adds the given key-value pairs to the session on the request.
Values that match keys already existing on the session will be overwritten. Values should
already be JSON serialized.
Examples
@@ -40,8 +40,8 @@ already be JSON serialized.
&mut req,
vec![("counter".to_string(), serde_json::to_string(&0).unwrap())],
);
-pub fn get_changes<B>(
res: &mut ServiceResponse<B>
) -> (SessionStatus, impl Iterator<Item = (String, String)>)
Returns session status and iterator of key-value pairs of changes.
-Trait Implementations
pub fn get_changes<B>(
res: &mut ServiceResponse<B>
) -> (SessionStatus, impl Iterator<Item = (String, String)>)
Returns session status and iterator of key-value pairs of changes.
+Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Session
impl !UnwindSafe for Session
Blanket Implementations
Immutably borrows from an owned value. Read more
diff --git a/actix_session/trait.UserSession.html b/actix_session/trait.UserSession.html
index b6eed8e45..5837703ba 100644
--- a/actix_session/trait.UserSession.html
+++ b/actix_session/trait.UserSession.html
@@ -1,7 +1,7 @@
UserSession in actix_session - Rust
- Trait actix_session::UserSession [−][src]
pub trait UserSession {
+ Trait actix_session::UserSession [−][src]
pub trait UserSession {
fn get_session(&self) -> Session;
}
Expand description
Extraction of a Session
object.
Required methods
fn get_session(&self) -> Session
Extract the Session
object
-Implementations on Foreign Types
Implementors
+
Implementations on Foreign Types
Implementors
\ No newline at end of file
diff --git a/actix_web_httpauth/middleware/index.html b/actix_web_httpauth/middleware/index.html
index a29411376..6825db35e 100644
--- a/actix_web_httpauth/middleware/index.html
+++ b/actix_web_httpauth/middleware/index.html
@@ -1,5 +1,5 @@
actix_web_httpauth::middleware - Rust
- Module actix_web_httpauth::middleware [−][src]
Expand description
HTTP Authentication middleware.
+ Module actix_web_httpauth::middleware [−][src]
Expand description
HTTP Authentication middleware.
Structs
Middleware for checking HTTP authentication.
diff --git a/actix_web_httpauth/middleware/struct.HttpAuthentication.html b/actix_web_httpauth/middleware/struct.HttpAuthentication.html
index 51ccee769..86386cd76 100644
--- a/actix_web_httpauth/middleware/struct.HttpAuthentication.html
+++ b/actix_web_httpauth/middleware/struct.HttpAuthentication.html
@@ -39,7 +39,7 @@ validation callback F
.
Trait Implementations
impl<S, B, T, F, O> Transform<S, ServiceRequest> for HttpAuthentication<T, F> where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error> + 'static,
S::Future: 'static,
F: Fn(ServiceRequest, T) -> O + 'static,
O: Future<Output = Result<ServiceRequest, Error>> + 'static,
T: AuthExtractor + 'static,
B: MessageBody + 'static,
B::Error: StdError,
type Response = ServiceResponse
Responses produced by the service.
+impl<S, B, T, F, O> Transform<S, ServiceRequest> for HttpAuthentication<T, F> where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error> + 'static,
S::Future: 'static,
F: Fn(ServiceRequest, T) -> O + 'static,
O: Future<Output = Result<ServiceRequest, Error>> + 'static,
T: AuthExtractor + 'static,
B: MessageBody + 'static,
B::Error: StdError,
type Response = ServiceResponse<EitherBody<B>>
Responses produced by the service.
type Error = Error
Errors produced by the service.
type Transform = AuthenticationMiddleware<S, F, T>
The TransformService
value created by this factory
Errors produced while building a transform service.
diff --git a/src/actix_cors/builder.rs.html b/src/actix_cors/builder.rs.html
index a4c74175d..a6b96b2a4 100644
--- a/src/actix_cors/builder.rs.html
+++ b/src/actix_cors/builder.rs.html
@@ -643,31 +643,20 @@
642
643
644
-645
-646
-647
-648
-649
-650
-651
-652
-653
-654
-655
-656
-657
-658
use std::{
collections::HashSet, convert::TryInto, error::Error as StdError, iter::FromIterator, rc::Rc,
};
use actix_utils::future::{self, Ready};
use actix_web::{
- body::MessageBody,
+ body::{EitherBody, MessageBody},
dev::{RequestHead, Service, ServiceRequest, ServiceResponse, Transform},
- error::{Error, Result},
- http::{self, header::HeaderName, Error as HttpError, HeaderValue, Method, Uri},
- Either,
+ error::HttpError,
+ http::{
+ header::{HeaderName, HeaderValue},
+ Method, Uri,
+ },
+ Either, Error, Result,
};
use log::error;
use once_cell::sync::Lazy;
@@ -679,7 +668,7 @@
/// Additionally, always causes first error (if any) to be reported during initialization.
fn cors<'a>(
inner: &'a mut Rc<Inner>,
- err: &Option<Either<http::Error, CorsError>>,
+ err: &Option<Either<HttpError, CorsError>>,
) -> Option<&'a mut Inner> {
if err.is_some() {
return None;
@@ -733,7 +722,7 @@
#[derive(Debug)]
pub struct Cors {
inner: Rc<Inner>,
- error: Option<Either<http::Error, CorsError>>,
+ error: Option<Either<HttpError, CorsError>>,
}
impl Cors {
@@ -1149,7 +1138,7 @@
B: MessageBody + 'static,
B::Error: StdError,
{
- type Response = ServiceResponse;
+ type Response = ServiceResponse<EitherBody<B>>;
type Error = Error;
type InitError = ();
type Transform = CorsMiddleware<S>;
@@ -1230,15 +1219,13 @@
#[cfg(test)]
mod test {
use std::convert::{Infallible, TryInto};
- use std::pin::Pin;
- use std::task::{Context, Poll};
use actix_web::{
- body::{BodySize, MessageBody},
+ body,
dev::{fn_service, Transform},
- http::{HeaderName, StatusCode},
+ http::{header::HeaderName, StatusCode},
test::{self, TestRequest},
- web::{Bytes, HttpResponse},
+ web::HttpResponse,
};
use super::*;
@@ -1293,23 +1280,8 @@
#[actix_rt::test]
async fn middleware_generic_over_body_type() {
- struct Foo;
-
- impl MessageBody for Foo {
- type Error = std::io::Error;
- fn size(&self) -> BodySize {
- BodySize::None
- }
- fn poll_next(
- self: Pin<&mut Self>,
- _: &mut Context<'_>,
- ) -> Poll<Option<Result<Bytes, Self::Error>>> {
- Poll::Ready(None)
- }
- }
-
let srv = fn_service(|req: ServiceRequest| async move {
- Ok(req.into_response(HttpResponse::Ok().message_body(Foo)?))
+ Ok(req.into_response(HttpResponse::Ok().message_body(body::None::new())?))
});
Cors::default().new_transform(srv).await.unwrap();
diff --git a/src/actix_cors/error.rs.html b/src/actix_cors/error.rs.html
index 6fc8d7cfb..3b6639f11 100644
--- a/src/actix_cors/error.rs.html
+++ b/src/actix_cors/error.rs.html
@@ -58,35 +58,35 @@
#[non_exhaustive]
pub enum CorsError {
/// Allowed origin argument must not be wildcard (`*`).
- #[display(fmt = "`allowed_origin` argument must not be wildcard (`*`).")]
+ #[display(fmt = "`allowed_origin` argument must not be wildcard (`*`)")]
WildcardOrigin,
/// Request header `Origin` is required but was not provided.
- #[display(fmt = "Request header `Origin` is required but was not provided.")]
+ #[display(fmt = "Request header `Origin` is required but was not provided")]
MissingOrigin,
/// Request header `Access-Control-Request-Method` is required but is missing.
- #[display(fmt = "Request header `Access-Control-Request-Method` is required but is missing.")]
+ #[display(fmt = "Request header `Access-Control-Request-Method` is required but is missing")]
MissingRequestMethod,
/// Request header `Access-Control-Request-Method` has an invalid value.
- #[display(fmt = "Request header `Access-Control-Request-Method` has an invalid value.")]
+ #[display(fmt = "Request header `Access-Control-Request-Method` has an invalid value")]
BadRequestMethod,
/// Request header `Access-Control-Request-Headers` has an invalid value.
- #[display(fmt = "Request header `Access-Control-Request-Headers` has an invalid value.")]
+ #[display(fmt = "Request header `Access-Control-Request-Headers` has an invalid value")]
BadRequestHeaders,
/// Origin is not allowed to make this request.
- #[display(fmt = "Origin is not allowed to make this request.")]
+ #[display(fmt = "Origin is not allowed to make this request")]
OriginNotAllowed,
/// Request method is not allowed.
- #[display(fmt = "Requested method is not allowed.")]
+ #[display(fmt = "Requested method is not allowed")]
MethodNotAllowed,
/// One or more request headers are not allowed.
- #[display(fmt = "One or more request headers are not allowed.")]
+ #[display(fmt = "One or more request headers are not allowed")]
HeadersNotAllowed,
}
@@ -96,7 +96,7 @@
}
fn error_response(&self) -> HttpResponse {
- HttpResponse::with_body(StatusCode::BAD_REQUEST, self.to_string().into())
+ HttpResponse::with_body(StatusCode::BAD_REQUEST, self.to_string()).map_into_boxed_body()
}
}
diff --git a/src/actix_cors/inner.rs.html b/src/actix_cors/inner.rs.html
index 894dfb5f9..35324928c 100644
--- a/src/actix_cors/inner.rs.html
+++ b/src/actix_cors/inner.rs.html
@@ -326,6 +326,9 @@
325
326
327
+328
+329
+330
use std::{collections::HashSet, convert::TryFrom, convert::TryInto, fmt, rc::Rc};
use actix_web::{
@@ -533,7 +536,10 @@
use actix_web::{
dev::Transform,
- http::{header, HeaderValue, Method, StatusCode},
+ http::{
+ header::{self, HeaderValue},
+ Method, StatusCode,
+ },
test::{self, TestRequest},
};
diff --git a/src/actix_cors/middleware.rs.html b/src/actix_cors/middleware.rs.html
index 8b9805eb2..e0ad4109c 100644
--- a/src/actix_cors/middleware.rs.html
+++ b/src/actix_cors/middleware.rs.html
@@ -240,11 +240,16 @@
239
240
241
+242
+243
+244
+245
+246
use std::{collections::HashSet, convert::TryInto, error::Error as StdError, rc::Rc};
-use actix_utils::future::{ok, Either, Ready};
+use actix_utils::future::ok;
use actix_web::{
- body::{AnyBody, MessageBody},
+ body::{EitherBody, MessageBody},
dev::{Service, ServiceRequest, ServiceResponse},
error::{Error, Result},
http::{
@@ -253,7 +258,7 @@
},
HttpResponse,
};
-use futures_util::future::{FutureExt as _, LocalBoxFuture, TryFutureExt as _};
+use futures_util::future::{FutureExt as _, LocalBoxFuture};
use log::debug;
use crate::{builder::intersperse_header_values, AllOrSome, Inner};
@@ -376,11 +381,6 @@
}
}
-type CorsMiddlewareServiceFuture = Either<
- Ready<Result<ServiceResponse, Error>>,
- LocalBoxFuture<'static, Result<ServiceResponse, Error>>,
->;
-
impl<S, B> Service<ServiceRequest> for CorsMiddleware<S>
where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
@@ -388,9 +388,9 @@
B: MessageBody + 'static,
B::Error: StdError,
{
- type Response = ServiceResponse;
+ type Response = ServiceResponse<EitherBody<B>>;
type Error = Error;
- type Future = CorsMiddlewareServiceFuture;
+ type Future = LocalBoxFuture<'static, Result<ServiceResponse<EitherBody<B>>, Error>>;
actix_service::forward_ready!(service);
@@ -398,7 +398,7 @@
if self.inner.preflight && req.method() == Method::OPTIONS {
let inner = Rc::clone(&self.inner);
let res = Self::handle_preflight(&inner, req);
- Either::left(ok(res))
+ ok(res.map_into_right_body()).boxed_local()
} else {
let origin = req.headers().get(header::ORIGIN).cloned();
@@ -406,27 +406,37 @@
// Only check requests with a origin header.
if let Err(err) = self.inner.validate_origin(req.head()) {
debug!("origin validation failed; inner service is not called");
- return Either::left(ok(req.error_response(err)));
+ return ok(req.error_response(err).map_into_right_body()).boxed_local();
}
}
+ let (req, pl) = req.into_parts();
+ let req2 = req.clone();
+ let req = ServiceRequest::from_parts(req, pl);
+
let inner = Rc::clone(&self.inner);
let fut = self.service.call(req);
- let res = async move {
+ async move {
let res = fut.await;
if origin.is_some() {
- let res = res?;
+ let res = match res {
+ Ok(res) => res,
+ Err(err) => {
+ let res = HttpResponse::from_error(err);
+ let res = ServiceResponse::new(req2, res);
+ return Ok(res.map_into_right_body());
+ }
+ };
+
Ok(Self::augment_response(&inner, res))
} else {
res
}
+ .map(|res| res.map_into_left_body())
}
- .map_ok(|res| res.map_body(|_, body| AnyBody::new_boxed(body)))
- .boxed_local();
-
- Either::right(res)
+ .boxed_local()
}
}
}
diff --git a/src/actix_identity/cookie.rs.html b/src/actix_identity/cookie.rs.html
index abd8d96c9..8cc9b8206 100644
--- a/src/actix_identity/cookie.rs.html
+++ b/src/actix_identity/cookie.rs.html
@@ -821,6 +821,13 @@
820
821
822
+823
+824
+825
+826
+827
+828
+829
use std::{rc::Rc, time::SystemTime};
use actix_utils::future::{ready, Ready};
@@ -1194,6 +1201,7 @@
use std::{borrow::Borrow, time::SystemTime};
use actix_web::{
+ body::{BoxBody, EitherBody},
cookie::{Cookie, CookieJar, Key, SameSite},
dev::ServiceResponse,
http::{header, StatusCode},
@@ -1231,7 +1239,7 @@
}
fn assert_login_cookie(
- response: &mut ServiceResponse,
+ response: &mut ServiceResponse<EitherBody<BoxBody>>,
identity: &str,
login_timestamp: LoginTimestampCheck,
visit_timestamp: VisitTimeStampCheck,
@@ -1400,13 +1408,19 @@
jar.get(COOKIE_NAME).unwrap().clone()
}
- async fn assert_logged_in(response: ServiceResponse, identity: Option<&str>) {
+ async fn assert_logged_in(
+ response: ServiceResponse<EitherBody<BoxBody>>,
+ identity: Option<&str>,
+ ) {
let bytes = test::read_body(response).await;
let resp: Option<String> = serde_json::from_slice(&bytes[..]).unwrap();
assert_eq!(resp.as_ref().map(|s| s.borrow()), identity);
}
- fn assert_legacy_login_cookie(response: &mut ServiceResponse, identity: &str) {
+ fn assert_legacy_login_cookie(
+ response: &mut ServiceResponse<EitherBody<BoxBody>>,
+ identity: &str,
+ ) {
let mut cookies = CookieJar::new();
for cookie in response.headers().get_all(header::SET_COOKIE) {
cookies.add(Cookie::parse(cookie.to_str().unwrap().to_string()).unwrap());
@@ -1418,7 +1432,7 @@
assert_eq!(cookie.value(), identity);
}
- fn assert_no_login_cookie(response: &mut ServiceResponse) {
+ fn assert_no_login_cookie(response: &mut ServiceResponse<EitherBody<BoxBody>>) {
let mut cookies = CookieJar::new();
for cookie in response.headers().get_all(header::SET_COOKIE) {
cookies.add(Cookie::parse(cookie.to_str().unwrap().to_string()).unwrap());
diff --git a/src/actix_identity/identity.rs.html b/src/actix_identity/identity.rs.html
index 49f48db6f..1362a3b3f 100644
--- a/src/actix_identity/identity.rs.html
+++ b/src/actix_identity/identity.rs.html
@@ -99,11 +99,11 @@
98
99
100
-
use actix_web::{
+
use actix_utils::future::{ready, Ready};
+use actix_web::{
dev::{Extensions, Payload},
Error, FromRequest, HttpRequest,
};
-use actix_utils::future::{ready, Ready};
pub(crate) struct IdentityItem {
pub(crate) id: Option<String>,
@@ -149,12 +149,12 @@
/// Return the claimed identity of the user associated request or `None` if no identity can be
/// found associated with the request.
pub fn identity(&self) -> Option<String> {
- Identity::get_identity(&self.0.extensions())
+ Identity::get_identity(&self.0.req_data())
}
/// Remember identity.
pub fn remember(&self, identity: String) {
- if let Some(id) = self.0.extensions_mut().get_mut::<IdentityItem>() {
+ if let Some(id) = self.0.req_data_mut().get_mut::<IdentityItem>() {
id.id = Some(identity);
id.changed = true;
}
@@ -162,7 +162,7 @@
/// This method is used to 'forget' the current identity on subsequent requests.
pub fn forget(&self) {
- if let Some(id) = self.0.extensions_mut().get_mut::<IdentityItem>() {
+ if let Some(id) = self.0.req_data_mut().get_mut::<IdentityItem>() {
id.id = None;
id.changed = true;
}
diff --git a/src/actix_identity/lib.rs.html b/src/actix_identity/lib.rs.html
index 69010de54..0fb0a6b39 100644
--- a/src/actix_identity/lib.rs.html
+++ b/src/actix_identity/lib.rs.html
@@ -152,6 +152,10 @@
151
152
153
+154
+155
+156
+157
//! Opinionated request identity service for Actix Web apps.
//!
//! [`IdentityService`] middleware can be used with different policies types to store
@@ -257,7 +261,11 @@
mod tests {
use std::time::SystemTime;
- use actix_web::{dev::ServiceResponse, test, web, App, Error};
+ use actix_web::{
+ body::{BoxBody, EitherBody},
+ dev::ServiceResponse,
+ test, web, App, Error,
+ };
use super::*;
@@ -284,7 +292,7 @@
f: F,
) -> impl actix_service::Service<
actix_http::Request,
- Response = ServiceResponse<actix_web::body::AnyBody>,
+ Response = ServiceResponse<EitherBody<BoxBody>>,
Error = Error,
> {
test::init_service(
diff --git a/src/actix_identity/middleware.rs.html b/src/actix_identity/middleware.rs.html
index 7d42f331b..3f61556e8 100644
--- a/src/actix_identity/middleware.rs.html
+++ b/src/actix_identity/middleware.rs.html
@@ -172,16 +172,15 @@
171
172
173
-174
use std::{error::Error as StdError, rc::Rc};
use actix_utils::future::{ready, Ready};
use actix_web::{
- body::{AnyBody, MessageBody},
+ body::{EitherBody, MessageBody},
dev::{Service, ServiceRequest, ServiceResponse, Transform},
Error, HttpMessage, Result,
};
-use futures_util::future::{FutureExt as _, LocalBoxFuture, TryFutureExt as _};
+use futures_util::future::{FutureExt as _, LocalBoxFuture};
use crate::{identity::IdentityItem, IdentityPolicy};
@@ -221,7 +220,7 @@
B: MessageBody + 'static,
B::Error: StdError,
{
- type Response = ServiceResponse;
+ type Response = ServiceResponse<EitherBody<B>>;
type Error = Error;
type InitError = ();
type Transform = IdentityServiceMiddleware<S, T>;
@@ -257,7 +256,7 @@
B: MessageBody + 'static,
B::Error: StdError,
{
- type Response = ServiceResponse;
+ type Response = ServiceResponse<EitherBody<B>>;
type Error = Error;
type Future = LocalBoxFuture<'static, Result<Self::Response, Self::Error>>;
@@ -279,17 +278,16 @@
if let Some(id) = id {
match backend.to_response(id.id, id.changed, &mut res).await {
- Ok(_) => Ok(res.map_body(|_, body| AnyBody::new_boxed(body))),
- Err(e) => Ok(res.error_response(e)),
+ Ok(_) => Ok(res.map_into_left_body()),
+ Err(err) => Ok(res.error_response(err).map_into_right_body()),
}
} else {
- Ok(res.map_body(|_, body| AnyBody::new_boxed(body)))
+ Ok(res.map_into_left_body())
}
}
- Err(err) => Ok(req.error_response(err)),
+ Err(err) => Ok(req.error_response(err).map_into_right_body()),
}
}
- .map_ok(|res| res.map_body(|_, body| AnyBody::new_boxed(body)))
.boxed_local()
}
}
diff --git a/src/actix_protobuf/lib.rs.html b/src/actix_protobuf/lib.rs.html
index bd50553ff..18bf0a98f 100644
--- a/src/actix_protobuf/lib.rs.html
+++ b/src/actix_protobuf/lib.rs.html
@@ -326,6 +326,9 @@
325
326
327
+328
+329
+330
#![forbid(unsafe_code)]
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible)]
@@ -339,6 +342,7 @@
};
use actix_web::{
+ body::BoxBody,
dev::Payload,
error::PayloadError,
http::header::{CONTENT_LENGTH, CONTENT_TYPE},
@@ -473,6 +477,8 @@
}
impl<T: Message + Default> Responder for ProtoBuf<T> {
+ type Body = BoxBody;
+
fn respond_to(self, _: &HttpRequest) -> HttpResponse {
let mut buf = Vec::new();
match self.0.encode(&mut buf) {
diff --git a/src/actix_redis/redis.rs.html b/src/actix_redis/redis.rs.html
index 11409d410..f3b5f4882 100644
--- a/src/actix_redis/redis.rs.html
+++ b/src/actix_redis/redis.rs.html
@@ -145,8 +145,8 @@
use actix::prelude::*;
use actix_rt::net::TcpStream;
-use actix_service::boxed::{service, BoxService};
-use actix_tls::connect::{ConnectError, ConnectInfo as Connect, Connection, Connector};
+use actix_service::boxed::{self, BoxService};
+use actix_tls::connect::{ConnectError, ConnectInfo, Connection, ConnectorService};
use backoff::backoff::Backoff;
use backoff::ExponentialBackoff;
use log::{error, info, warn};
@@ -169,7 +169,7 @@
/// Redis communication actor
pub struct RedisActor {
addr: String,
- connector: BoxService<Connect<String>, Connection<String, TcpStream>, ConnectError>,
+ connector: BoxService<ConnectInfo<String>, Connection<String, TcpStream>, ConnectError>,
backoff: ExponentialBackoff,
cell: Option<actix::io::FramedWrite<RespValue, WriteHalf<TcpStream>, RespCodec>>,
queue: VecDeque<oneshot::Sender<Result<RespValue, Error>>>,
@@ -187,7 +187,7 @@
Supervisor::start(|_| RedisActor {
addr,
- connector: service(Connector::default().service()),
+ connector: boxed::service(ConnectorService::default()),
cell: None,
backoff,
queue: VecDeque::new(),
@@ -199,7 +199,7 @@
type Context = Context<Self>;
fn started(&mut self, ctx: &mut Context<Self>) {
- let req = Connect::new(self.addr.to_owned());
+ let req = ConnectInfo::new(self.addr.to_owned());
self.connector
.call(req)
.into_actor(self)
diff --git a/src/actix_session/cookie.rs.html b/src/actix_session/cookie.rs.html
index 9938bfced..b80d7036f 100644
--- a/src/actix_session/cookie.rs.html
+++ b/src/actix_session/cookie.rs.html
@@ -569,10 +569,10 @@
use actix_utils::future::{ok, Ready};
use actix_web::{
- body::{AnyBody, MessageBody},
+ body::{EitherBody, MessageBody},
cookie::{Cookie, CookieJar, Key, SameSite},
dev::{Service, ServiceRequest, ServiceResponse, Transform},
- http::{header::SET_COOKIE, HeaderValue},
+ http::header::{HeaderValue, SET_COOKIE},
Error, ResponseError,
};
use derive_more::Display;
@@ -868,7 +868,7 @@
B: MessageBody + 'static,
B::Error: StdError,
{
- type Response = ServiceResponse;
+ type Response = ServiceResponse<EitherBody<B>>;
type Error = S::Error;
type InitError = ();
type Transform = CookieSessionMiddleware<S>;
@@ -896,7 +896,7 @@
B: MessageBody + 'static,
B::Error: StdError,
{
- type Response = ServiceResponse;
+ type Response = ServiceResponse<EitherBody<B>>;
type Error = S::Error;
type Future = LocalBoxFuture<'static, Result<Self::Response, Self::Error>>;
@@ -944,8 +944,8 @@
};
match result {
- Ok(()) => Ok(res.map_body(|_, body| AnyBody::new_boxed(body))),
- Err(error) => Ok(res.error_response(error)),
+ Ok(()) => Ok(res.map_into_left_body()),
+ Err(error) => Ok(res.error_response(error).map_into_right_body()),
}
}
.boxed_local()
diff --git a/src/actix_session/lib.rs.html b/src/actix_session/lib.rs.html
index a70b91fe0..b6ba6eb53 100644
--- a/src/actix_session/lib.rs.html
+++ b/src/actix_session/lib.rs.html
@@ -379,26 +379,6 @@
378
379
380
-381
-382
-383
-384
-385
-386
-387
-388
-389
-390
-391
-392
-393
-394
-395
-396
-397
-398
-399
-400
//! Sessions for Actix Web.
//!
//! Provides a general solution for session management. Session middleware could provide different
@@ -452,7 +432,7 @@
use actix_utils::future::{ok, Ready};
use actix_web::{
- dev::{Extensions, Payload, RequestHead, ServiceRequest, ServiceResponse},
+ dev::{Extensions, Payload, ServiceRequest, ServiceResponse},
Error, FromRequest, HttpMessage, HttpRequest,
};
use serde::{de::DeserializeOwned, Serialize};
@@ -502,12 +482,6 @@
}
}
-impl UserSession for RequestHead {
- fn get_session(&self) -> Session {
- Session::get_session(&mut *self.extensions_mut())
- }
-}
-
/// Status of a [`Session`].
#[derive(PartialEq, Clone, Debug)]
pub enum SessionStatus {
@@ -756,20 +730,6 @@
assert_eq!(res, Some(true));
}
- #[actix_web::test]
- async fn get_session_from_request_head() {
- let mut req = test::TestRequest::default().to_srv_request();
-
- Session::set_session(
- &mut req,
- vec![("key".to_string(), serde_json::to_string(&10).unwrap())],
- );
-
- let session = req.head_mut().get_session();
- let res = session.get::<u32>("key").unwrap();
- assert_eq!(res, Some(10));
- }
-
#[actix_web::test]
async fn purge_session() {
let req = test::TestRequest::default().to_srv_request();
diff --git a/src/actix_web_httpauth/middleware.rs.html b/src/actix_web_httpauth/middleware.rs.html
index 9a8dead30..50c0ed522 100644
--- a/src/actix_web_httpauth/middleware.rs.html
+++ b/src/actix_web_httpauth/middleware.rs.html
@@ -359,9 +359,6 @@
358
359
360
-361
-362
-363
//! HTTP Authentication middleware.
use std::{
@@ -375,7 +372,7 @@
};
use actix_web::{
- body::{AnyBody, MessageBody},
+ body::{EitherBody, MessageBody},
dev::{Service, ServiceRequest, ServiceResponse, Transform},
Error,
};
@@ -491,7 +488,7 @@
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 = ();
@@ -526,9 +523,9 @@
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);
@@ -541,7 +538,7 @@
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());
}
};
@@ -549,10 +546,7 @@
// 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()
}