Struct salvo::http::Request [−][src]
pub struct Request { /* fields omitted */ }
Expand description
Represents an HTTP request.
Stores all the properties of the client’s request.
Implementations
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 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 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
lsit 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.
pub async fn read_from_json<T>(&'_ mut self) -> Result<T, ReadError> where
T: DeserializeOwned,
pub async fn read_from_json<T>(&'_ mut self) -> Result<T, ReadError> where
T: DeserializeOwned,
Read body as type T
from request.
pub async fn read_from_form<T>(&'_ mut self) -> Result<T, ReadError> where
T: DeserializeOwned,
pub async fn read_from_form<T>(&'_ mut self) -> Result<T, ReadError> where
T: DeserializeOwned,
Read body as type T
from request.
Read body as type T
from request.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Request
impl !UnwindSafe for Request
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
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