pub struct Request { /* private fields */ }Expand description
HTTP Request wrapper that provides convenient access to request data
Implementations§
Source§impl Request
impl Request
Sourcepub async fn from_hyper(
parts: Parts,
body: Incoming,
) -> Result<Self, Box<dyn Error + Send + Sync>>
pub async fn from_hyper( parts: Parts, body: Incoming, ) -> Result<Self, Box<dyn Error + Send + Sync>>
Create a new Request from hyper’s request parts and body
Sourcepub fn body_string(&self) -> Result<String, FromUtf8Error>
pub fn body_string(&self) -> Result<String, FromUtf8Error>
Get the request body as a string
Sourcepub async fn json<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
pub async fn json<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
Parse the request body as JSON (requires “json” feature)
Sourcepub fn path_params(&self) -> &HashMap<String, String>
pub fn path_params(&self) -> &HashMap<String, String>
Get all path parameters (for extractors)
Sourcepub fn extensions(&self) -> &HashMap<TypeId, Box<dyn Any + Send + Sync>>
pub fn extensions(&self) -> &HashMap<TypeId, Box<dyn Any + Send + Sync>>
Get a reference to the request extensions
Sourcepub fn extensions_mut(
&mut self,
) -> &mut HashMap<TypeId, Box<dyn Any + Send + Sync>>
pub fn extensions_mut( &mut self, ) -> &mut HashMap<TypeId, Box<dyn Any + Send + Sync>>
Get a mutable reference to the request extensions
Sourcepub fn insert_extension<T: Send + Sync + 'static>(&mut self, value: T)
pub fn insert_extension<T: Send + Sync + 'static>(&mut self, value: T)
Insert a value into the request extensions
Sourcepub fn get_extension<T: Send + Sync + 'static>(&self) -> Option<&T>
pub fn get_extension<T: Send + Sync + 'static>(&self) -> Option<&T>
Get a value from the request extensions
Sourcepub fn query_params(&self) -> &HashMap<String, String>
pub fn query_params(&self) -> &HashMap<String, String>
Get all query parameters
Sourcepub fn query_string(&self) -> Option<&str>
pub fn query_string(&self) -> Option<&str>
Get the raw query string
Sourcepub fn body_bytes(&self) -> &[u8] ⓘ
pub fn body_bytes(&self) -> &[u8] ⓘ
Get the request body as bytes (for extractors)
Sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Get mutable access to headers (for extractors)
Trait Implementations§
Source§impl RequestStateExt for Request
Implementation of RequestStateExt for Request
impl RequestStateExt for Request
Implementation of RequestStateExt for Request
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