Struct actix_web::HttpRequest [−][src]
pub struct HttpRequest<S = ()> { /* fields omitted */ }
An HTTP Request
Methods
impl<S> HttpRequest<S>[src]
impl<S> HttpRequest<S>ⓘImportant traits for &'a mut Rpub fn state(&self) -> &S[src]
pub fn state(&self) -> &SShared application state
pub fn request(&self) -> &Request[src]
pub fn request(&self) -> &RequestServer request
pub fn extensions(&self) -> Ref<Extensions>[src]
pub fn extensions(&self) -> Ref<Extensions>Request extensions
pub fn extensions_mut(&self) -> RefMut<Extensions>[src]
pub fn extensions_mut(&self) -> RefMut<Extensions>Mutable reference to a the request's extensions
pub fn response(&self, status: StatusCode, body: Body) -> HttpResponse[src]
pub fn response(&self, status: StatusCode, body: Body) -> HttpResponseCreate http response
pub fn build_response(&self, status: StatusCode) -> HttpResponseBuilder[src]
pub fn build_response(&self, status: StatusCode) -> HttpResponseBuilderCreate http response builder
pub fn uri(&self) -> &Uri[src]
pub fn uri(&self) -> &UriRead the Request Uri.
pub fn method(&self) -> &Method[src]
pub fn method(&self) -> &MethodRead the Request method.
pub fn version(&self) -> Version[src]
pub fn version(&self) -> VersionRead the Request Version.
pub fn path(&self) -> &str[src]
pub fn path(&self) -> &strThe target path of this Request.
pub fn connection_info(&self) -> Ref<ConnectionInfo>[src]
pub fn connection_info(&self) -> Ref<ConnectionInfo>Get ConnectionInfo for the correct request.
pub fn url_for<U, I>(
&self,
name: &str,
elements: U
) -> Result<Url, UrlGenerationError> where
U: IntoIterator<Item = I>,
I: AsRef<str>, [src]
pub fn url_for<U, I>(
&self,
name: &str,
elements: U
) -> Result<Url, UrlGenerationError> where
U: IntoIterator<Item = I>,
I: AsRef<str>, Generate url for named resource
fn index(req: HttpRequest) -> HttpResponse { let url = req.url_for("foo", &["1", "2", "3"]); // <- generate url for "foo" resource HttpResponse::Ok().into() } fn main() { let app = App::new() .resource("/test/{one}/{two}/{three}", |r| { r.name("foo"); // <- set resource name, then it could be used in `url_for` r.method(http::Method::GET).f(|_| HttpResponse::Ok()); }) .finish(); }
pub fn url_for_static(&self, name: &str) -> Result<Url, UrlGenerationError>[src]
pub fn url_for_static(&self, name: &str) -> Result<Url, UrlGenerationError>Generate url for named resource
This method is similar to HttpRequest::url_for() but it can be used
for urls that do not contain variable parts.
pub fn resource(&self) -> &ResourceInfo[src]
pub fn resource(&self) -> &ResourceInfoThis method returns reference to current RouteInfo object.
pub fn peer_addr(&self) -> Option<SocketAddr>[src]
pub fn peer_addr(&self) -> Option<SocketAddr>Peer socket address
Peer address is actual socket address, if proxy is used in front of actix http server, then peer address would be address of this proxy.
To get client connection information connection_info() method should
be used.
pub fn query(&self) -> Ref<HashMap<String, String>>[src]
pub fn query(&self) -> Ref<HashMap<String, String>>url query parameters.
pub fn query_string(&self) -> &str[src]
pub fn query_string(&self) -> &strThe query string in the URL.
E.g., id=10
Load request cookies.
Return request cookie.
pub fn match_info(&self) -> &Params[src]
pub fn match_info(&self) -> &ParamsGet a reference to the Params object.
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.
pub fn set_read_buffer_capacity(&mut self, cap: usize)[src]
pub fn set_read_buffer_capacity(&mut self, cap: usize)Set read buffer capacity
Default buffer capacity is 32Kb.
Methods from Deref<Target = Request>
pub fn uri(&self) -> &Uri[src]
pub fn uri(&self) -> &UriRead the Request Uri.
pub fn method(&self) -> &Method[src]
pub fn method(&self) -> &MethodRead the Request method.
pub fn version(&self) -> Version[src]
pub fn version(&self) -> VersionRead the Request Version.
pub fn path(&self) -> &str[src]
pub fn path(&self) -> &strThe target path of this Request.
pub fn headers(&self) -> &HeaderMap[src]
pub fn headers(&self) -> &HeaderMapReturns Request's headers.
pub fn peer_addr(&self) -> Option<SocketAddr>[src]
pub fn peer_addr(&self) -> Option<SocketAddr>Peer socket address
Peer address is actual socket address, if proxy is used in front of actix http server, then peer address would be address of this proxy.
To get client connection information connection_info() method should
be used.
pub fn keep_alive(&self) -> bool[src]
pub fn keep_alive(&self) -> boolChecks if a connection should be kept alive.
pub fn extensions(&self) -> Ref<Extensions>[src]
pub fn extensions(&self) -> Ref<Extensions>Request extensions
pub fn extensions_mut(&self) -> RefMut<Extensions>[src]
pub fn extensions_mut(&self) -> RefMut<Extensions>Mutable reference to a the request's extensions
pub fn upgrade(&self) -> bool[src]
pub fn upgrade(&self) -> boolCheck if request requires connection upgrade
pub fn connection_info(&self) -> Ref<ConnectionInfo>[src]
pub fn connection_info(&self) -> Ref<ConnectionInfo>Get ConnectionInfo for the correct request.
pub fn server_settings(&self) -> &ServerSettings[src]
pub fn server_settings(&self) -> &ServerSettingsServer settings
Trait Implementations
impl<S> HttpMessage for HttpRequest<S>[src]
impl<S> HttpMessage for HttpRequest<S>type Stream = Payload
Type of message payload stream
fn headers(&self) -> &HeaderMap[src]
fn headers(&self) -> &HeaderMapRead the message headers.
fn payload(&self) -> Payload[src]
fn payload(&self) -> PayloadMessage payload stream
fn content_type(&self) -> &str[src]
fn content_type(&self) -> &strRead the request content type. If request does not contain Content-Type header, empty str get returned. Read more
fn encoding(&self) -> Result<EncodingRef, ContentTypeError>[src]
fn encoding(&self) -> Result<EncodingRef, ContentTypeError>Get content type encoding Read more
fn mime_type(&self) -> Result<Option<Mime>, ContentTypeError>[src]
fn mime_type(&self) -> Result<Option<Mime>, ContentTypeError>Convert the request content type to a known mime type.
fn chunked(&self) -> Result<bool, ParseError>[src]
fn chunked(&self) -> Result<bool, ParseError>Check if request has chunked transfer encoding
fn body(&self) -> MessageBody<Self>[src]
fn body(&self) -> MessageBody<Self>Load http message body. Read more
fn urlencoded<T: DeserializeOwned>(&self) -> UrlEncoded<Self, T>[src]
fn urlencoded<T: DeserializeOwned>(&self) -> UrlEncoded<Self, T>Parse application/x-www-form-urlencoded encoded request's body. Return UrlEncoded future. Form can be deserialized to any type that implements Deserialize trait from serde. Read more
fn json<T: DeserializeOwned>(&self) -> JsonBody<Self, T>[src]
fn json<T: DeserializeOwned>(&self) -> JsonBody<Self, T>Parse application/json encoded body. Return JsonBody<T> future. It resolves to a T value. Read more
fn multipart(&self) -> Multipart<Self::Stream>[src]
fn multipart(&self) -> Multipart<Self::Stream>Return stream to http payload processes as multipart. Read more
fn readlines(&self) -> Readlines<Self>[src]
fn readlines(&self) -> Readlines<Self>Return stream of lines.
impl<S> Deref for HttpRequest<S>[src]
impl<S> Deref for HttpRequest<S>type Target = Request
The resulting type after dereferencing.
fn deref(&self) -> &Request[src]
fn deref(&self) -> &RequestDereferences the value.
impl<S> Drop for HttpRequest<S>[src]
impl<S> Drop for HttpRequest<S>impl<S> Clone for HttpRequest<S>[src]
impl<S> Clone for HttpRequest<S>fn clone(&self) -> HttpRequest<S>[src]
fn clone(&self) -> HttpRequest<S>Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl<S> FromRequest<S> for HttpRequest<S>[src]
impl<S> FromRequest<S> for HttpRequest<S>type Config = ()
Configuration for conversion process
type Result = Self
Future that resolves to a Self
fn from_request(req: &HttpRequest<S>, _: &Self::Config) -> Self::Result[src]
fn from_request(req: &HttpRequest<S>, _: &Self::Config) -> Self::ResultConvert request to a Self
fn extract(req: &HttpRequest<S>) -> Self::Result[src]
fn extract(req: &HttpRequest<S>) -> Self::ResultConvert request to a Self Read more
impl<S> Debug for HttpRequest<S>[src]
impl<S> Debug for HttpRequest<S>fn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl<'a, S> From<&'a HttpRequest<S>> for HttpResponseBuilder[src]
impl<'a, S> From<&'a HttpRequest<S>> for HttpResponseBuilderfn from(req: &'a HttpRequest<S>) -> HttpResponseBuilder[src]
fn from(req: &'a HttpRequest<S>) -> HttpResponseBuilderPerforms the conversion.
impl<'a, S: 'static> From<&'a HttpRequest<S>> for ClientRequestBuilder[src]
impl<'a, S: 'static> From<&'a HttpRequest<S>> for ClientRequestBuilderCreate ClientRequestBuilder from HttpRequest
It is useful for proxy requests. This implementation copies all request headers and the method.
fn from(req: &'a HttpRequest<S>) -> ClientRequestBuilder[src]
fn from(req: &'a HttpRequest<S>) -> ClientRequestBuilderPerforms the conversion.
impl<S> RequestIdentity for HttpRequest<S>[src]
impl<S> RequestIdentity for HttpRequest<S>fn identity(&self) -> Option<String>[src]
fn identity(&self) -> Option<String>Return the claimed identity of the user associated request or None if no identity can be found associated with the request. Read more
fn remember(&self, identity: String)[src]
fn remember(&self, identity: String)Remember identity.
fn forget(&self)[src]
fn forget(&self)This method is used to 'forget' the current identity on subsequent requests. Read more
impl<S> RequestSession for HttpRequest<S>[src]
impl<S> RequestSession for HttpRequest<S>Auto Trait Implementations
impl<S = ()> !Send for HttpRequest<S>
impl<S = ()> !Send for HttpRequest<S>impl<S = ()> !Sync for HttpRequest<S>
impl<S = ()> !Sync for HttpRequest<S>