Struct salvo::prelude::Request

source ·
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.

Modify a header for this request.

When overwrite is set to true, If the header is already present, the value will be replaced. When overwrite is set to false, The new header is always appended to the request, even if the header already exists.

Modify a header for this request.

When overwrite is set to true, If the header is already present, the value will be replaced. When overwrite is set to false, The new header is always appended to the request, even if the header already exists.

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 field data from form, if key is not found in form data, then get from query.

Get value from query, if key is not found in queries, then get 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 request payload.

*Notice: This method takes body.

Get FormData reference from request.

*Notice: This method takes body.

Extract request as type T from request’s different parts.

Extract request as type T from request’s different parts.

Parse url params as type T from request.

Parse queries as type T from request.

Parse headers as type T from request.

Parse cookies as type T from request.

Parse json body as type T from request.

Parse form body as type T from request.

Parse json body or form 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.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
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