[−]Struct tide::Request
An HTTP request.
The Request
gives endpoints access to basic information about the incoming
request, route parameters, and various ways of accessing the request's body.
Requests also provide extensions, a type map primarily used for low-level communication between middleware and endpoints.
Methods
impl<State> Request<State>
[src]
pub fn method(&self) -> &Method
[src]
Access the request's HTTP method.
pub fn uri(&self) -> &Uri
[src]
Access the request's full URI method.
pub fn version(&self) -> Version
[src]
Access the request's HTTP version.
pub fn headers(&self) -> &HeaderMap
[src]
Access the request's headers.
pub fn header(&self, key: &'static str) -> Option<&str>
[src]
Get an HTTP header.
pub fn set_header(self, key: &'static str, value: impl AsRef<str>) -> Self
[src]
Set an HTTP header.
pub fn local<T: Send + Sync + 'static>(&self) -> Option<&T>
[src]
Get a local value.
pub fn set_local<T: Send + Sync + 'static>(self, val: T) -> Self
[src]
Set a local value.
pub fn state(&self) -> &State
[src]
Access app-global state.
pub fn param<T: FromStr>(&self, key: &str) -> Result<T, T::Err>
[src]
Extract and parse a route parameter by name.
Returns the results of parsing the parameter according to the inferred
output type T
.
The name should not include the leading :
or the trailing *
(if
any).
Errors
Yields an Err
if the parameter was found but failed to parse as an
instance of type T
.
Panics
Panic if key
is not a parameter for the route.
pub async fn body_bytes<'_>(&'_ mut self) -> Result<Vec<u8>>
[src]
Reads the entire request body into a byte buffer.
This method can be called after the body has already been read, but will produce an empty buffer.
Errors
Any I/O error encountered while reading the body is immediately returned
as an Err
.
pub async fn body_string<'_>(&'_ mut self) -> Result<String>
[src]
Reads the entire request body into a string.
This method can be called after the body has already been read, but will produce an empty buffer.
Errors
Any I/O error encountered while reading the body is immediately returned
as an Err
.
If the body cannot be interpreted as valid UTF-8, an Err
is returned.
pub async fn body_json<'_, T: DeserializeOwned>(&'_ mut self) -> Result<T>
[src]
Reads and deserialized the entire request body via json.
Errors
Any I/O error encountered while reading the body is immediately returned
as an Err
.
If the body cannot be interpreted as valid json for the target type T
,
an Err
is returned.
pub fn query<'de, T: Deserialize<'de>>(&'de self) -> Result<T, Error>
[src]
Get the URL querystring.
pub async fn body_form<'_, T: DeserializeOwned>(&'_ mut self) -> Result<T>
[src]
Parse the request body as a form.
Trait Implementations
impl<State: Send + Sync + 'static> IntoResponse for Request<State>
[src]
fn into_response(self) -> Response
[src]
fn with_status(self, status: StatusCode) -> WithStatus<Self>
[src]
impl<'__pin, State> Unpin for Request<State> where
__Origin<'__pin, State>: Unpin,
__Origin<'__pin, State>: Unpin,
impl<State: Debug> Debug for Request<State>
[src]
impl<State> AsyncRead for Request<State>
[src]
Auto Trait Implementations
impl<State> Send for Request<State> where
State: Send + Sync,
State: Send + Sync,
impl<State> !Sync for Request<State>
impl<State> !UnwindSafe for Request<State>
impl<State> !RefUnwindSafe for Request<State>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> ReadExt for T where
T: AsyncRead + ?Sized,
[src]
T: AsyncRead + ?Sized,
fn read(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self> where
Self: Unpin,
[src]
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self> where
Self: Unpin,
fn read_to_end(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEndFuture<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn read_to_string(
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self> where
Self: Unpin,
[src]
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self> where
Self: Unpin,
fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn take(self, limit: u64) -> Take<Self>
[src]
fn by_ref(&mut self) -> &mut Self
[src]
fn bytes(self) -> Bytes<Self>
[src]
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: AsyncRead,
[src]
R: AsyncRead,
impl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
[src]
R: AsyncRead + ?Sized,
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: AsyncRead,
[src]
R: AsyncRead,
fn read(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> where
Self: Unpin,
[src]
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> where
Self: Unpin,
fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn read_to_end(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn read_to_string(&'a mut self, buf: &'a mut String) -> ReadToString<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>) where
Self: AsyncWrite,
[src]
Self: AsyncWrite,
fn take(self, limit: u64) -> Take<Self>
[src]
fn compat(self) -> Compat<Self> where
Self: Unpin,
[src]
Self: Unpin,