pub struct ServiceRequest { /* private fields */ }
Expand description
A service level request wrapper.
Allows mutable access to request’s internal structures.
Implementations§
Source§impl ServiceRequest
impl ServiceRequest
Sourcepub fn into_parts(self) -> (HttpRequest, Payload)
pub fn into_parts(self) -> (HttpRequest, Payload)
Deconstruct ServiceRequest
into inner parts.
Sourcepub fn parts_mut(&mut self) -> (&mut HttpRequest, &mut Payload)
pub fn parts_mut(&mut self) -> (&mut HttpRequest, &mut Payload)
Returns mutable accessors to inner parts.
Sourcepub fn parts(&self) -> (&HttpRequest, &Payload)
pub fn parts(&self) -> (&HttpRequest, &Payload)
Returns immutable accessors to inner parts.
Sourcepub fn request(&self) -> &HttpRequest
pub fn request(&self) -> &HttpRequest
Returns immutable accessor to inner HttpRequest
.
Sourcepub fn extract<T>(&mut self) -> <T as FromRequest>::Futurewhere
T: FromRequest,
pub fn extract<T>(&mut self) -> <T as FromRequest>::Futurewhere
T: FromRequest,
Derives a type from this request using an extractor.
Returns the T
extractor’s Future
type which can be await
ed. 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?;
// [...]
}
Sourcepub fn from_parts(req: HttpRequest, payload: Payload) -> ServiceRequest
pub fn from_parts(req: HttpRequest, payload: Payload) -> ServiceRequest
Construct request from parts.
Sourcepub fn from_request(req: HttpRequest) -> ServiceRequest
pub fn from_request(req: HttpRequest) -> ServiceRequest
Construct ServiceRequest
with no payload from given HttpRequest
.
Sourcepub fn into_response<B, R>(self, res: R) -> ServiceResponse<B>
pub fn into_response<B, R>(self, res: R) -> ServiceResponse<B>
Create ServiceResponse
from this request and given response.
Sourcepub fn error_response<E>(self, err: E) -> ServiceResponse
pub fn error_response<E>(self, err: E) -> ServiceResponse
Create ServiceResponse
from this request and given error.
Sourcepub fn head(&self) -> &RequestHead
pub fn head(&self) -> &RequestHead
Returns a reference to the request head.
Sourcepub fn head_mut(&mut self) -> &mut RequestHead
pub fn head_mut(&mut self) -> &mut RequestHead
Returns a mutable reference to the request head.
Sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Returns a mutable reference to request headers.
Sourcepub fn query_string(&self) -> &str
pub fn query_string(&self) -> &str
Counterpart to HttpRequest::query_string
.
Sourcepub fn peer_addr(&self) -> Option<SocketAddr>
pub fn peer_addr(&self) -> Option<SocketAddr>
Returns peer’s socket address.
See HttpRequest::peer_addr
for more details.
Sourcepub fn connection_info(&self) -> Ref<'_, ConnectionInfo>
pub fn connection_info(&self) -> Ref<'_, ConnectionInfo>
Returns a reference to connection info.
Sourcepub fn match_info(&self) -> &Path<Url>
pub fn match_info(&self) -> &Path<Url>
Counterpart to HttpRequest::match_info
.
Sourcepub fn match_info_mut(&mut self) -> &mut Path<Url>
pub fn match_info_mut(&mut self) -> &mut Path<Url>
Returns a mutable reference to the path match information.
Sourcepub fn match_name(&self) -> Option<&str>
pub fn match_name(&self) -> Option<&str>
Counterpart to HttpRequest::match_name
.
Sourcepub fn match_pattern(&self) -> Option<String>
pub fn match_pattern(&self) -> Option<String>
Counterpart to HttpRequest::match_pattern
.
Sourcepub fn resource_map(&self) -> &ResourceMap
pub fn resource_map(&self) -> &ResourceMap
Returns a reference to the application’s resource map.
Counterpart to HttpRequest::resource_map
.
Sourcepub fn app_config(&self) -> &AppConfig
pub fn app_config(&self) -> &AppConfig
Counterpart to HttpRequest::app_config
.
Sourcepub fn app_data<T>(&self) -> Option<&T>where
T: 'static,
pub fn app_data<T>(&self) -> Option<&T>where
T: 'static,
Counterpart to HttpRequest::app_data
.
Sourcepub fn conn_data<T>(&self) -> Option<&T>where
T: 'static,
pub fn conn_data<T>(&self) -> Option<&T>where
T: 'static,
Counterpart to HttpRequest::conn_data
.
Return request cookies.
Return request cookie.
Sourcepub fn set_payload(&mut self, payload: Payload)
pub fn set_payload(&mut self, payload: Payload)
Set request payload.
Sourcepub fn add_data_container(&mut self, extensions: Rc<Extensions>)
pub fn add_data_container(&mut self, extensions: Rc<Extensions>)
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.
Sourcepub fn guard_ctx(&self) -> GuardContext<'_>
pub fn guard_ctx(&self) -> GuardContext<'_>
Creates a context object for use with a routing guard.
Trait Implementations§
Source§impl Debug for ServiceRequest
impl Debug for ServiceRequest
Source§impl HttpMessage for ServiceRequest
impl HttpMessage for ServiceRequest
Source§type Stream = Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>>>>
type Stream = Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>>>>
Source§fn extensions(&self) -> Ref<'_, Extensions>
fn extensions(&self) -> Ref<'_, Extensions>
Source§fn extensions_mut(&self) -> RefMut<'_, Extensions>
fn extensions_mut(&self) -> RefMut<'_, Extensions>
Source§fn take_payload(&mut self) -> Payload<<ServiceRequest as HttpMessage>::Stream>
fn take_payload(&mut self) -> Payload<<ServiceRequest as HttpMessage>::Stream>
Source§fn content_type(&self) -> &str
fn content_type(&self) -> &str
Source§fn encoding(&self) -> Result<&'static Encoding, ContentTypeError>
fn encoding(&self) -> Result<&'static Encoding, ContentTypeError>
Source§impl Resource for ServiceRequest
impl Resource for ServiceRequest
Source§impl<S, B> Service<ServiceRequest> for JwtAuthService<S>where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
S::Future: 'static,
B: MessageBody + 'static,
impl<S, B> Service<ServiceRequest> for JwtAuthService<S>where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
S::Future: 'static,
B: MessageBody + 'static,
Source§type Error = <S as Service<ServiceRequest>>::Error
type Error = <S as Service<ServiceRequest>>::Error
Source§type Future = Pin<Box<dyn Future<Output = Result<<JwtAuthService<S> as Service<ServiceRequest>>::Response, <JwtAuthService<S> as Service<ServiceRequest>>::Error>>>>
type Future = Pin<Box<dyn Future<Output = Result<<JwtAuthService<S> as Service<ServiceRequest>>::Response, <JwtAuthService<S> as Service<ServiceRequest>>::Error>>>>
Source§impl<S, B> Transform<S, ServiceRequest> for JwtAuthwhere
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
B: MessageBody + 'static,
S::Future: 'static,
impl<S, B> Transform<S, ServiceRequest> for JwtAuthwhere
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
B: MessageBody + 'static,
S::Future: 'static,
Source§type Transform = JwtAuthService<S>
type Transform = JwtAuthService<S>
TransformService
value created by this factorySource§type Future = Ready<Result<<JwtAuth as Transform<S, ServiceRequest>>::Transform, <JwtAuth as Transform<S, ServiceRequest>>::InitError>>
type Future = Ready<Result<<JwtAuth as Transform<S, ServiceRequest>>::Transform, <JwtAuth as Transform<S, ServiceRequest>>::InitError>>
Source§fn new_transform(&self, service: S) -> Self::Future
fn new_transform(&self, service: S) -> Self::Future
Auto Trait Implementations§
impl Freeze for ServiceRequest
impl !RefUnwindSafe for ServiceRequest
impl !Send for ServiceRequest
impl !Sync for ServiceRequest
impl Unpin for ServiceRequest
impl !UnwindSafe for ServiceRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more