[]Struct paperclip::actix::web::HttpRequest

pub struct HttpRequest(_);

An HTTP Request

Methods

impl HttpRequest

pub fn head(&self) -> &RequestHead

This method returns reference to the request head

pub fn uri(&self) -> &Uri

Request's uri.

pub fn method(&self) -> &Method

Read the Request method.

pub fn version(&self) -> Version

Read the Request Version.

pub fn headers(&self) -> &HeaderMap

Returns request's headers.

pub fn path(&self) -> &str

The target path of this Request.

pub fn query_string(&self) -> &str

The query string in the URL.

E.g., id=10

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.

pub fn extensions(&self) -> Ref<Extensions>

Request extensions

pub fn extensions_mut(&self) -> RefMut<Extensions>

Mutable reference to a the request's extensions

pub fn url_for<U, I>(
    &self,
    name: &str,
    elements: U
) -> Result<Url, UrlGenerationError> where
    I: AsRef<str>,
    U: IntoIterator<Item = I>, 

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>

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_map(&self) -> &ResourceMap

Get a reference to a ResourceMap of current application.

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() should be used.

pub fn connection_info(&self) -> Ref<ConnectionInfo>

Get ConnectionInfo for the current request.

This method panics if request's extensions container is already borrowed.

pub fn app_config(&self) -> &AppConfig

App config

pub fn app_data<T>(&self) -> Option<&T> where
    T: 'static, 

Get an application data stored with App::extension() method during application configuration.

Trait Implementations

impl Apiv2Schema for HttpRequest[src]

impl Clone for HttpRequest

impl Debug for HttpRequest

impl Drop for HttpRequest

impl FromRequest for HttpRequest

It is possible to get HttpRequest as an extractor handler parameter

Example

use actix_web::{web, App, HttpRequest};
use serde_derive::Deserialize;

/// extract `Thing` from request
async 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 Config = ()

Configuration for this extractor

type Error = Error

The associated error which can be returned.

type Future = Ready<Result<HttpRequest, Error>>

Future that resolves to a Self

impl HttpMessage for HttpRequest

type Stream = ()

Type of message payload stream

fn headers(&self) -> &HeaderMap

Returns Request's headers.

fn extensions(&self) -> Ref<Extensions>

Request extensions

fn extensions_mut(&self) -> RefMut<Extensions>

Mutable reference to a the request's extensions

impl OperationModifier for HttpRequest[src]

Auto Trait Implementations

impl !RefUnwindSafe for HttpRequest

impl !Send for HttpRequest

impl !Sync for HttpRequest

impl Unpin for HttpRequest

impl !UnwindSafe for HttpRequest

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Apiv2Schema for T where
    T: TypedData
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,