Struct highnoon::Request

source ·
pub struct Request<S: State> { /* private fields */ }
Expand description

An incoming request

Implementations

Get a reference to the App’s state

Get a reference to the request’s context

Get a mut reference to the request’s context

Get the HTTP method being used by this request

Get the URI that was used for this request

Parse the URI query string into an instance of T that derives Deserialize.

(To get the raw query string access it via req.uri().query()). If there is no query string, deserialize an empty string.

Get a typed header from the request (See also headers)

Get all headers as a HeaderMap

Get the request’s cookies

Get a route parameter (eg. :key or *key segments in the URI path)

If the parameter is not present, logs an error and returns a 400 Bad Request to the client

Get all route parameters

Get the request body as a hyper::Body

Get a reader to read the request body

(This does buffer the whole body into memory, but not necessarily contiguous memory). If you need to protect against malicious clients you should access the body via body_mut

Get the request body as raw bytes in a Vec<u8>

Get the request body as UTF-8 data in String

Get the request body as JSON and deserialize into T.

If deserialization fails, log an error and return 400 Bad Request. (If this logic is not appropriate, consider using reader and using serde_json directly)

Get the address of the remote peer.

This method uses the network level address only and hence may be incorrect if you are behind a proxy. (This does not check for any Forwarded headers etc…)

Trait Implementations

Implement HasSession on requests where the Context has sessions

Get a reference to the Session for this current request

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more