pub struct ServiceRequest(/* private fields */);Expand description
An service http request
ServiceRequest 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 request into parts
Sourcepub fn from_parts(
req: HttpRequest,
pl: Payload,
) -> Result<Self, (HttpRequest, Payload)>
pub fn from_parts( req: HttpRequest, pl: Payload, ) -> Result<Self, (HttpRequest, Payload)>
Construct request from parts.
ServiceRequest can be re-constructed only if req hasnt been cloned.
Sourcepub fn from_request(req: HttpRequest) -> Result<Self, HttpRequest>
pub fn from_request(req: HttpRequest) -> Result<Self, HttpRequest>
Construct request from request.
HttpRequest implements Clone trait via Rc type. ServiceRequest
can be re-constructed only if rc’s strong pointers count eq 1 and
weak pointers count is 0.
Sourcepub fn into_response<B, R: Into<Response<B>>>(
self,
res: R,
) -> ServiceResponse<B>
pub fn into_response<B, R: Into<Response<B>>>( self, res: R, ) -> ServiceResponse<B>
Create service response
Sourcepub fn error_response<B, E: Into<Error>>(self, err: E) -> ServiceResponse<B>
pub fn error_response<B, E: Into<Error>>(self, err: E) -> ServiceResponse<B>
Create service response for error
Sourcepub fn head(&self) -> &RequestHead
pub fn head(&self) -> &RequestHead
This method returns reference to the request head
Sourcepub fn head_mut(&mut self) -> &mut RequestHead
pub fn head_mut(&mut self) -> &mut RequestHead
This method returns reference to the request head
Sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Returns mutable request’s headers.
Sourcepub fn query_string(&self) -> &str
pub fn query_string(&self) -> &str
The query string in the URL.
E.g., id=10
Sourcepub fn peer_addr(&self) -> Option<SocketAddr>
pub fn peer_addr(&self) -> Option<SocketAddr>
Peer socket address
Peer address is actual socket address, if proxy is used in front of Eternal http server, then peer address would be address of this proxy.
To get client connection information ConnectionInfo should be used.
Sourcepub fn connection_info(&self) -> Ref<'_, ConnectionInfo>
pub fn connection_info(&self) -> Ref<'_, ConnectionInfo>
Get ConnectionInfo for the current request.
Sourcepub fn match_info(&self) -> &Path<Url>
pub fn match_info(&self) -> &Path<Url>
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.
Sourcepub fn match_info_mut(&mut self) -> &mut Path<Url>
pub fn match_info_mut(&mut self) -> &mut Path<Url>
Get a mutable reference to the Path parameters.
Sourcepub fn resource_map(&self) -> &ResourceMap
pub fn resource_map(&self) -> &ResourceMap
Get a reference to a ResourceMap of current application.
Sourcepub fn app_config(&self) -> &AppConfig
pub fn app_config(&self) -> &AppConfig
Service configuration
Sourcepub fn app_data<T: 'static>(&self) -> Option<Data<T>>
pub fn app_data<T: 'static>(&self) -> Option<Data<T>>
Get an application data stored with App::data() method during
application configuration.
Sourcepub fn set_payload(&mut self, payload: Payload)
pub fn set_payload(&mut self, payload: Payload)
Set request payload.
Trait Implementations§
Source§impl Debug for ServiceRequest
impl Debug for ServiceRequest
Source§impl HttpMessage for ServiceRequest
impl HttpMessage for ServiceRequest
Source§fn extensions(&self) -> Ref<'_, Extensions>
fn extensions(&self) -> Ref<'_, Extensions>
Request extensions
Source§fn extensions_mut(&self) -> RefMut<'_, Extensions>
fn extensions_mut(&self) -> RefMut<'_, Extensions>
Mutable reference to a the request’s extensions
Source§type Stream = Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>>>>
type Stream = Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>>>>
Source§fn take_payload(&mut self) -> Payload<Self::Stream>
fn take_payload(&mut self) -> Payload<Self::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§fn mime_type(&self) -> Result<Option<Mime>, ContentTypeError>
fn mime_type(&self) -> Result<Option<Mime>, ContentTypeError>
Source§impl Resource<Url> for ServiceRequest
impl Resource<Url> for ServiceRequest
fn resource_path(&mut self) -> &mut Path<Url>
Auto Trait Implementations§
impl !RefUnwindSafe for ServiceRequest
impl !Send for ServiceRequest
impl !Sync for ServiceRequest
impl !UnwindSafe for ServiceRequest
impl Freeze for ServiceRequest
impl Unpin for ServiceRequest
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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