logo
pub struct Request { /* private fields */ }
Expand description

Represents an HTTP request.

Stores all the properties of the client’s request.

Implementations

Creates a new blank Request

Returns a reference to the associated URI.

Examples
let req = Request::default();
assert_eq!(*req.uri(), *"/");

Returns a mutable reference to the associated URI.

Examples
let mut req: Request= Request::default();
*req.uri_mut() = "/hello".parse().unwrap();
assert_eq!(*req.uri(), *"/hello");

Returns a reference to the associated HTTP method.

Examples
let req = Request::default();
assert_eq!(*req.method(), Method::GET);

Returns a mutable reference to the associated HTTP method.

Examples
let mut request: Request = Request::default();
*request.method_mut() = Method::PUT;
assert_eq!(*request.method(), Method::PUT);

Returns the associated version.

Returns a mutable reference to the associated version.

Get request remote address.

Returns a reference to the associated header field map.

Examples
let req = Request::default();
assert!(req.headers().is_empty());

Returns a mutable reference to the associated header field map.

Examples
let mut req: Request = Request::default();
req.headers_mut().insert(HOST, HeaderValue::from_static("world"));
assert!(!req.headers().is_empty());

Get header with supplied name and try to parse to a ‘T’, returns None if failed or not found.

Returns a reference to the associated HTTP body.

Examples
let req = Request::default();
assert!(req.body().is_some());

Returns a mutable reference to the associated HTTP body.

Take body form the request, and set the body to None in the request.

Returns a reference to the associated extensions.

Examples
let req = Request::default();
assert!(req.extensions().get::<i32>().is_none());

Returns a mutable reference to the associated extensions.

Examples
let mut req = Request::default();
req.extensions_mut().insert("hello");
assert_eq!(req.extensions().get(), Some(&"hello"));

Get accept.

Get first accept.

Get content type.

Get CookieJar reference.

Get CookieJar mutable reference.

Get Cookie from cookies.

Get params reference.

Get params mutable reference.

Get param value from params.

Get queries reference.

Get query value from queries.

Get field data from form.

Get FilePart reference from request.

Get FilePart reference from request.

Get FilePart list reference from request.

Get FilePart list reference from request.

Get value from form first if not found then get from query.

Get value from query first if not found then get from form.

Get request payload.

Get FormData reference from request.

Read body as text from request.

Read body as type T from request.

Read body as type T from request.

Read body as type T from request.

Read body as type T from request.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Converts to this type from the input type.

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