pub struct Request { /* private fields */ }Expand description
HTTP Request wrapper
Provides access to all parts of an incoming HTTP request.
Implementations§
Source§impl Request
impl Request
Sourcepub fn extensions(&self) -> &Extensions
pub fn extensions(&self) -> &Extensions
Get request extensions
Sourcepub fn extensions_mut(&mut self) -> &mut Extensions
pub fn extensions_mut(&mut self) -> &mut Extensions
Get mutable extensions
Sourcepub fn query_string(&self) -> Option<&str>
pub fn query_string(&self) -> Option<&str>
Get the query string
Sourcepub fn take_body(&mut self) -> Option<Bytes>
pub fn take_body(&mut self) -> Option<Bytes>
Take the body bytes (can only be called once)
Returns None if the body is streaming or already consumed.
Use load_body().await first if you need to ensure the body is available as bytes.
Sourcepub fn take_stream(&mut self) -> Option<Incoming>
pub fn take_stream(&mut self) -> Option<Incoming>
Take the body as a stream (can only be called once)
Sourcepub async fn load_body(&mut self) -> Result<(), ApiError>
pub async fn load_body(&mut self) -> Result<(), ApiError>
Ensure the body is loaded into memory.
If the body is streaming, this collects it into Bytes. If already buffered, does nothing. Returns error if collection fails.
Sourcepub fn path_params(&self) -> &PathParams
pub fn path_params(&self) -> &PathParams
Get path parameters
Sourcepub fn path_param(&self, name: &str) -> Option<&String>
pub fn path_param(&self, name: &str) -> Option<&String>
Get a specific path parameter
Sourcepub fn state(&self) -> &Arc<Extensions>
pub fn state(&self) -> &Arc<Extensions>
Get shared state
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