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 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
Trait Implementations§
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