pub struct Request { /* private fields */ }Expand description
HTTP request
A request is composed of:
- HTTP method (
GET,POST,PUT,DELETE, … ) - Target URL, for example,
https://myservice.com/users - (optional) Request headers.
- (optional) Request path parameters, for example,
idin the URLhttps://myservice.com/users?id=1111. - (optional) Server cookies
- (optional) Request body
Request headers, parameters and cookies are represented by a pair of name and value strings.
For more information see HTTP Request.
Implementations§
Source§impl Request
impl Request
Sourcepub fn method(&self) -> HttpMethod
pub fn method(&self) -> HttpMethod
Gets HTTP Method
Sourcepub fn insert_param<K, V>(&mut self, key: K, value: V) -> &mut Self
pub fn insert_param<K, V>(&mut self, key: K, value: V) -> &mut Self
Insert a request param with key and value. Param keys are case-sensitive.
Sourcepub fn params(&self) -> &KeyValueMap
pub fn params(&self) -> &KeyValueMap
Gets a params map reference
Sourcepub fn params_mut(&mut self) -> &mut KeyValueMap
pub fn params_mut(&mut self) -> &mut KeyValueMap
Gets a mutable params map reference
Insert a cookie param with key and value. Param keys are case-sensitive.
Gets a cookie map reference
Gets a mutable params map reference
Methods from Deref<Target = HttpMessage>§
Sourcepub fn insert_header<K, V>(&mut self, key: K, value: V) -> &mut Self
pub fn insert_header<K, V>(&mut self, key: K, value: V) -> &mut Self
Inserts a header with key and value
Sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Gets a mutable reference to the headers map
Sourcepub fn has_single_body(&self) -> bool
pub fn has_single_body(&self) -> bool
Checks if the request has a single body
Sourcepub fn has_multipart_body(&self) -> bool
pub fn has_multipart_body(&self) -> bool
Checks if the request has a multi-part body
Sourcepub fn body(&self) -> Option<&Vec<u8>>
pub fn body(&self) -> Option<&Vec<u8>>
Gets body data if any, returns None if there is no single body
Trait Implementations§
Source§impl Deref for Request
impl Deref for Request
Source§type Target = HttpMessage
type Target = HttpMessage
The resulting type after dereferencing.
Source§fn deref(&self) -> &HttpMessage
fn deref(&self) -> &HttpMessage
Dereferences the value.
Auto Trait Implementations§
impl Freeze for Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnwindSafe for Request
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more