Struct salvo::Request[][src]

pub struct Request { /* fields omitted */ }
Expand description

Represents an HTTP request.

Stores all the properties of the client’s request.

Implementations

Creates a new blank Request

Create a request from an hyper::Request.

This constructor consumes the hyper::Request.

Returns a reference to the associated URI.

Examples

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

Returns a mutable reference to the associated URI.

Examples

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

Returns a reference to the associated HTTP method.

Examples

let request = Request::default();
assert_eq!(*request.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.

Returns a reference to the associated header field map.

Examples

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

Returns a mutable reference to the associated header field map.

Examples

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

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

Returns a reference to the associated HTTP body.

Examples

let request = Request::default();
assert!(request.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 request = Request::default();
assert!(request.extensions().get::<i32>().is_none());

Returns a mutable reference to the associated extensions.

Examples

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

Trait Implementations

Formats the value using the given formatter. Read more

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

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

Performs the conversion.

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

Performs the conversion.

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.