[−][src]Struct actix_web::web::HttpRequest
An HTTP Request
Methods
impl HttpRequest
[src]
pub fn head(&self) -> &RequestHead
[src]
This method returns reference to the request head
pub fn uri(&self) -> &Uri
[src]
Request's uri.
pub fn method(&self) -> &Method
[src]
Read the Request method.
pub fn version(&self) -> Version
[src]
Read the Request Version.
pub fn headers(&self) -> &HeaderMap
[src]
Returns request's headers.
pub fn path(&self) -> &str
[src]
The target path of this Request.
pub fn query_string(&self) -> &str
[src]
The query string in the URL.
E.g., id=10
pub fn match_info(&self) -> &Path<Url>
[src]
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.
pub fn extensions(&self) -> Ref<Extensions>
[src]
Request extensions
pub fn extensions_mut(&self) -> RefMut<Extensions>
[src]
Mutable reference to a the request's extensions
pub fn url_for<U, I>(
&self,
name: &str,
elements: U
) -> Result<Url, UrlGenerationError> where
U: IntoIterator<Item = I>,
I: AsRef<str>,
[src]
&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() .service(web::resource("/test/{one}/{two}/{three}") .name("foo") // <- set resource name, then it could be used in `url_for` .route(web::get().to(|| HttpResponse::Ok())) ); }
pub fn url_for_static(&self, name: &str) -> Result<Url, UrlGenerationError>
[src]
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 connection_info(&self) -> Ref<ConnectionInfo>
[src]
Get ConnectionInfo for the current request.
pub fn app_config(&self) -> &AppConfig
[src]
App config
pub fn app_data<T: 'static>(&self) -> Option<Data<T>>
[src]
Get an application data stored with App::data()
method during
application configuration.
pub fn route_data<T: 'static>(&self) -> Option<&RouteData<T>>
[src]
Load route data. Route data could be set during
route configuration with Route::data()
method.
Trait Implementations
impl<P> FromRequest<P> for HttpRequest
[src]
It is possible to get HttpRequest
as an extractor handler parameter
Example
use actix_web::{web, App, HttpRequest}; /// extract `Thing` from request fn index(req: HttpRequest) -> String { format!("Got thing: {:?}", req) } fn main() { let app = App::new().service( web::resource("/users/{first}").route( web::get().to(index)) ); }
type Error = Error
The associated error which can be returned.
type Future = Result<Self, Error>
Future that resolves to a Self
fn from_request(req: &HttpRequest, _: &mut Payload<P>) -> Self::Future
[src]
fn extract(req: &HttpRequest) -> Self::Future
[src]
Convert request to a Self Read more
impl Clone for HttpRequest
[src]
fn clone(&self) -> HttpRequest
[src]
default fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Drop for HttpRequest
[src]
impl Debug for HttpRequest
[src]
impl HttpMessage for HttpRequest
[src]
type Stream = ()
Type of message payload stream
fn headers(&self) -> &HeaderMap
[src]
Returns Request's headers.
fn extensions(&self) -> Ref<Extensions>
[src]
Request extensions
fn extensions_mut(&self) -> RefMut<Extensions>
[src]
Mutable reference to a the request's extensions
fn take_payload(&mut self) -> Payload<Self::Stream>
[src]
default fn content_type(&self) -> &str
[src]
Read the request content type. If request does not contain Content-Type header, empty str get returned. Read more
default fn encoding(
&self
) -> Result<&'static (dyn Encoding + 'static + Send + Sync), ContentTypeError>
[src]
&self
) -> Result<&'static (dyn Encoding + 'static + Send + Sync), ContentTypeError>
Get content type encoding Read more
default fn mime_type(&self) -> Result<Option<Mime>, ContentTypeError>
[src]
Convert the request content type to a known mime type.
default fn chunked(&self) -> Result<bool, ParseError>
[src]
Check if request has chunked transfer encoding
default fn cookies(&self) -> Result<Ref<Vec<Cookie<'static>>>, ParseError>
[src]
Load request cookies.
default fn cookie(&self, name: &str) -> Option<Cookie<'static>>
[src]
Return request cookie.
Auto Trait Implementations
impl !Send for HttpRequest
impl !Sync for HttpRequest
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,