Struct ntex::web::WebRequest[][src]

pub struct WebRequest<Err> { /* fields omitted */ }
Expand description

An service http request

WebRequest allows mutable access to request’s internal structures

Implementations

impl<Err: ErrorRenderer> WebRequest<Err>[src]

pub fn render_error<E: WebResponseError<Err>>(self, err: E) -> WebResponse[src]

Create web response for error

pub fn error_response<E: Into<Err::Container>>(self, err: E) -> WebResponse[src]

Create web response for error

impl<Err> WebRequest<Err>[src]

pub fn into_parts(self) -> (HttpRequest, Payload)[src]

Deconstruct request into parts

pub fn from_parts(
    req: HttpRequest,
    pl: Payload
) -> Result<Self, (HttpRequest, Payload)>
[src]

Construct request from parts.

WebRequest can be re-constructed only if req hasnt been cloned.

pub fn from_request(req: HttpRequest) -> Result<Self, HttpRequest>[src]

Construct request from request.

HttpRequest implements Clone trait via Rc type. WebRequest can be re-constructed only if rc’s strong pointers count eq 1 and weak pointers count is 0.

pub fn into_response<R: Into<Response>>(self, res: R) -> WebResponse[src]

Create web response

pub fn head(&self) -> &RequestHead[src]

This method returns reference to the request head

pub fn head_mut(&mut self) -> &mut 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 headers_mut(&mut self) -> &mut HeaderMap[src]

Returns mutable 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 peer_addr(&self) -> Option<SocketAddr>[src]

Peer socket address

Peer address is actual socket address, if proxy is used in front of ntex http server, then peer address would be address of this proxy.

To get client connection information ConnectionInfo should be used.

pub fn connection_info(&self) -> Ref<'_, ConnectionInfo>[src]

Get ConnectionInfo for the current request.

pub fn match_info(&self) -> &Path<Uri>[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 match_info_mut(&mut self) -> &mut Path<Uri>[src]

Get a mutable reference to the Path parameters.

pub fn resource_map(&self) -> &ResourceMap[src]

Get a reference to a ResourceMap of current application.

pub fn app_config(&self) -> &AppConfig[src]

Service configuration

pub fn app_data<T: 'static>(&self) -> Option<&T>[src]

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

To get data stored with App::data() use web::types::Data<T> as type.

pub fn take_payload(&mut self) -> Payload[src]

Get request’s payload

pub fn set_payload(&mut self, payload: Payload)[src]

Set request payload.

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

Trait Implementations

impl<Err: ErrorRenderer> Debug for WebRequest<Err>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<Err> HttpMessage for WebRequest<Err>[src]

fn message_headers(&self) -> &HeaderMap[src]

Returns Request’s headers.

fn message_extensions(&self) -> Ref<'_, Extensions>[src]

Request extensions

fn message_extensions_mut(&self) -> RefMut<'_, Extensions>[src]

Mutable reference to a the request’s extensions

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

fn encoding(&self) -> Result<&'static Encoding, ContentTypeError>[src]

Get content type encoding Read more

fn mime_type(&self) -> Result<Option<Mime>, ContentTypeError>[src]

Convert the request content type to a known mime type.

fn chunked(&self) -> Result<bool, ParseError>[src]

Check if request has chunked transfer encoding

fn cookies(&self) -> Result<Ref<'_, Vec<Cookie<'static>>>, ParseError>[src]

Load request cookies.

fn cookie(&self, name: &str) -> Option<Cookie<'static>>[src]

Return request cookie.

impl<Err> Resource<Uri> for WebRequest<Err>[src]

fn path(&self) -> &str[src]

fn resource_path(&mut self) -> &mut Path<Uri>[src]

Auto Trait Implementations

impl<Err> !RefUnwindSafe for WebRequest<Err>

impl<Err> !Send for WebRequest<Err>

impl<Err> !Sync for WebRequest<Err>

impl<Err> Unpin for WebRequest<Err> where
    Err: Unpin

impl<Err> !UnwindSafe for WebRequest<Err>

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.