Struct ajars_actix_web::actix_web::dev::ServiceRequest [−][src]
pub struct ServiceRequest { /* fields omitted */ }
Expand description
An service http request
ServiceRequest allows mutable access to request’s internal structures
Implementations
pub fn into_parts(
self
) -> (HttpRequest, Payload<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>)
pub fn into_parts(
self
) -> (HttpRequest, Payload<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>)
Deconstruct request into parts
Get mutable access to inner HttpRequest
and Payload
pub fn from_parts(
req: HttpRequest,
payload: Payload<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>
) -> ServiceRequest
pub fn from_parts(
req: HttpRequest,
payload: Payload<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>
) -> ServiceRequest
Construct request from parts.
Construct request from request.
The returned ServiceRequest
would have no payload.
Create service response
Create service response for error
This method returns reference to the request head
This method returns reference to the request head
Returns mutable request’s headers.
The query string in the URL.
E.g., id=10
Peer socket address.
Peer address is the directly connected peer’s socket address. If a proxy is used in front of the Actix Web server, then it would be address of this proxy.
To get client connection information ConnectionInfo
should be used.
Will only return None when called in unit tests.
Get ConnectionInfo for the current request.
Get a reference to the Path parameters.
Params is a container for url parameters.
A variable segment is specified in the form {identifier}
,
where the identifier can be used later in a request handler to
access the matched value for that segment.
Counterpart to HttpRequest::match_name
.
Counterpart to HttpRequest::match_pattern
.
Get a mutable reference to the Path parameters.
Get a reference to a ResourceMap
of current application.
Service configuration
Counterpart to HttpRequest::app_data
.
pub fn set_payload(
&mut self,
payload: Payload<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>
)
pub fn set_payload(
&mut self,
payload: Payload<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>
)
Set request payload.
Add data container to request’s resolution set.
In middleware, prefer extensions_mut
for request-local
data since it is assumed that the same app data is presented for every request.
Trait Implementations
Request extensions
Mutable reference to a the request’s extensions
Type of message payload stream
Message payload stream
fn content_type(&self) -> &str
fn content_type(&self) -> &str
Read the request content type. If request did not contain a Content-Type header, an empty string is returned. Read more
fn encoding(&self) -> Result<&'static Encoding, ContentTypeError>
fn encoding(&self) -> Result<&'static Encoding, ContentTypeError>
Get content type encoding Read more
fn mime_type(&self) -> Result<Option<Mime>, ContentTypeError>
fn mime_type(&self) -> Result<Option<Mime>, ContentTypeError>
Convert the request content type to a known mime type.
fn chunked(&self) -> Result<bool, ParseError>
fn chunked(&self) -> Result<bool, ParseError>
Check if request has chunked transfer encoding.
type Response = ServiceResponse<AnyBody>
type Response = ServiceResponse<AnyBody>
Responses given by the created services.
type Service = RouteService
type Service = RouteService
The kind of Service
created by this factory.
type Future = Pin<Box<dyn Future<Output = Result<<Route as ServiceFactory<ServiceRequest>>::Service, <Route as ServiceFactory<ServiceRequest>>::InitError>> + 'static, Global>>
type Future = Pin<Box<dyn Future<Output = Result<<Route as ServiceFactory<ServiceRequest>>::Service, <Route as ServiceFactory<ServiceRequest>>::InitError>> + 'static, Global>>
The future of the Service
instance.g
Create and return a new service asynchronously.
impl<S, B> Transform<S, ServiceRequest> for DefaultHeaders where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
<S as Service<ServiceRequest>>::Future: 'static,
impl<S, B> Transform<S, ServiceRequest> for DefaultHeaders where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
<S as Service<ServiceRequest>>::Future: 'static,
type Response = ServiceResponse<B>
type Response = ServiceResponse<B>
Responses produced by the service.
type Transform = DefaultHeadersMiddleware<S>
type Transform = DefaultHeadersMiddleware<S>
The TransformService
value created by this factory
type Future = Ready<Result<<DefaultHeaders as Transform<S, ServiceRequest>>::Transform, <DefaultHeaders as Transform<S, ServiceRequest>>::InitError>>
type Future = Ready<Result<<DefaultHeaders as Transform<S, ServiceRequest>>::Transform, <DefaultHeaders as Transform<S, ServiceRequest>>::InitError>>
The future response value.
pub fn new_transform(
&self,
service: S
) -> <DefaultHeaders as Transform<S, ServiceRequest>>::Future
pub fn new_transform(
&self,
service: S
) -> <DefaultHeaders as Transform<S, ServiceRequest>>::Future
Creates and returns a new Transform component, asynchronously
impl<S, B> Transform<S, ServiceRequest> for ErrorHandlers<B> where
B: 'static,
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error> + 'static,
<S as Service<ServiceRequest>>::Future: 'static,
impl<S, B> Transform<S, ServiceRequest> for ErrorHandlers<B> where
B: 'static,
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error> + 'static,
<S as Service<ServiceRequest>>::Future: 'static,
type Response = ServiceResponse<B>
type Response = ServiceResponse<B>
Responses produced by the service.
type Transform = ErrorHandlersMiddleware<S, B>
type Transform = ErrorHandlersMiddleware<S, B>
The TransformService
value created by this factory
type Future = Pin<Box<dyn Future<Output = Result<<ErrorHandlers<B> as Transform<S, ServiceRequest>>::Transform, <ErrorHandlers<B> as Transform<S, ServiceRequest>>::InitError>> + 'static, Global>>
type Future = Pin<Box<dyn Future<Output = Result<<ErrorHandlers<B> as Transform<S, ServiceRequest>>::Transform, <ErrorHandlers<B> as Transform<S, ServiceRequest>>::InitError>> + 'static, Global>>
The future response value.
pub fn new_transform(
&self,
service: S
) -> <ErrorHandlers<B> as Transform<S, ServiceRequest>>::Future
pub fn new_transform(
&self,
service: S
) -> <ErrorHandlers<B> as Transform<S, ServiceRequest>>::Future
Creates and returns a new Transform component, asynchronously
impl<S, B> Transform<S, ServiceRequest> for Logger where
B: MessageBody,
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
impl<S, B> Transform<S, ServiceRequest> for Logger where
B: MessageBody,
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
type Response = ServiceResponse<StreamLog<B>>
type Response = ServiceResponse<StreamLog<B>>
Responses produced by the service.
type Transform = LoggerMiddleware<S>
type Transform = LoggerMiddleware<S>
The TransformService
value created by this factory
type Future = Ready<Result<<Logger as Transform<S, ServiceRequest>>::Transform, <Logger as Transform<S, ServiceRequest>>::InitError>>
type Future = Ready<Result<<Logger as Transform<S, ServiceRequest>>::Transform, <Logger as Transform<S, ServiceRequest>>::InitError>>
The future response value.
Creates and returns a new Transform component, asynchronously
impl<S, B> Transform<S, ServiceRequest> for NormalizePath where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
<S as Service<ServiceRequest>>::Future: 'static,
impl<S, B> Transform<S, ServiceRequest> for NormalizePath where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
<S as Service<ServiceRequest>>::Future: 'static,
type Response = ServiceResponse<B>
type Response = ServiceResponse<B>
Responses produced by the service.
type Transform = NormalizePathNormalization<S>
type Transform = NormalizePathNormalization<S>
The TransformService
value created by this factory
type Future = Ready<Result<<NormalizePath as Transform<S, ServiceRequest>>::Transform, <NormalizePath as Transform<S, ServiceRequest>>::InitError>>
type Future = Ready<Result<<NormalizePath as Transform<S, ServiceRequest>>::Transform, <NormalizePath as Transform<S, ServiceRequest>>::InitError>>
The future response value.
pub fn new_transform(
&self,
service: S
) -> <NormalizePath as Transform<S, ServiceRequest>>::Future
pub fn new_transform(
&self,
service: S
) -> <NormalizePath as Transform<S, ServiceRequest>>::Future
Creates and returns a new Transform component, asynchronously
Auto Trait Implementations
impl !RefUnwindSafe for ServiceRequest
impl !Send for ServiceRequest
impl !Sync for ServiceRequest
impl Unpin for ServiceRequest
impl !UnwindSafe for ServiceRequest