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
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 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"));
pub async fn read_from_json<T>(&'_ mut self) -> Result<T, ReadError> where
T: DeserializeOwned,
pub async fn read_from_form<T>(&'_ mut self) -> Result<T, ReadError> where
T: DeserializeOwned,
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Request
impl !UnwindSafe for Request