logo
pub struct ServiceRequest { /* private fields */ }
Expand description

A service level request wrapper.

Allows mutable access to request’s internal structures.

Implementations

Deconstruct ServiceRequest into inner parts.

Returns mutable accessors to inner parts.

Returns immutable accessors to inner parts.

Returns immutable accessor to inner HttpRequest.

Derives a type from this request using an extractor.

Returns the T extractor’s Future type which can be awaited. This is particularly handy when you want to use an extractor in a middleware implementation.

Examples
use actix_web::{
    dev::{ServiceRequest, ServiceResponse},
    web::Path, Error
};

async fn my_helper(mut srv_req: ServiceRequest) -> Result<ServiceResponse, Error> {
    let path = srv_req.extract::<Path<(String, u32)>>().await?;
    // [...]
}

Construct request from parts.

Construct ServiceRequest with no payload from given HttpRequest.

Create ServiceResponse from this request and given response.

Create ServiceResponse from this request and given error.

Returns a reference to the request head.

Returns a mutable reference to the request head.

Returns the request URI.

Returns the request method.

Returns the request version.

Returns a reference to request headers.

Returns a mutable reference to request headers.

Returns request path.

Counterpart to HttpRequest::query_string.

Returns peer’s 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.

Returns a reference to connection info.

Returns 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.

Returns a mutable reference to the path match information.

Counterpart to HttpRequest::match_name.

Returns a reference to the application’s resource map.

Returns a reference to the application’s configuration.

Counterpart to HttpRequest::app_data.

Counterpart to HttpRequest::conn_data.

Return request cookies.

Return request cookie.

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.

Creates a context object for use with a guard.

Useful if you are implementing

Trait Implementations

Formats the value using the given formatter. Read more

Type of message payload stream

Read the message headers.

Returns a reference to the request-local data/extensions container.

Returns a mutable reference to the request-local data/extensions container.

Message payload stream

Read the request content type. If request did not contain a Content-Type header, an empty string is returned. Read more

Get content type encoding. Read more

Convert the request content type to a known mime type.

Check if request has chunked transfer encoding.

Type of resource’s path returned in resource_path.

Responses given by the created services.

Errors produced by the created services.

Service factory configuration.

The kind of Service created by this factory.

Errors potentially raised while building a service.

The future of the Service instance.g

Create and return a new service asynchronously.

Responses produced by the service.

Errors produced by the service.

The TransformService value created by this factory

Errors produced while building a transform service.

The future response value.

Creates and returns a new Transform component, asynchronously

Responses produced by the service.

Errors produced by the service.

The TransformService value created by this factory

Errors produced while building a transform service.

The future response value.

Creates and returns a new Transform component, asynchronously

Responses produced by the service.

Errors produced by the service.

The TransformService value created by this factory

Errors produced while building a transform service.

The future response value.

Creates and returns a new Transform component, asynchronously

Responses produced by the service.

Errors produced by the service.

The TransformService value created by this factory

Errors produced while building a transform service.

The future response value.

Creates and returns a new Transform component, asynchronously

Responses produced by the service.

Errors produced by the service.

The TransformService value created by this factory

Errors produced while building a transform service.

The future response value.

Creates and returns a new Transform component, asynchronously

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more