pub struct Request { /* private fields */ }
Expand description
A unified request object that can represent both incoming and outgoing requests.
This should be used in favor of IncomingRequest
and OutgoingRequest
when there
is no need for streaming bodies.
Implementations§
source§impl Request
impl Request
sourcepub fn new(method: Method, uri: impl Into<String>) -> Self
pub fn new(method: Method, uri: impl Into<String>) -> Self
Creates a new request from a method and uri
sourcepub fn builder() -> RequestBuilder
pub fn builder() -> RequestBuilder
Creates a RequestBuilder
sourcepub fn get(uri: impl Into<String>) -> RequestBuilder
pub fn get(uri: impl Into<String>) -> RequestBuilder
Creates a RequestBuilder
to GET the given uri
sourcepub fn post(uri: impl Into<String>, body: impl IntoBody) -> RequestBuilder
pub fn post(uri: impl Into<String>, body: impl IntoBody) -> RequestBuilder
Creates a RequestBuilder
to POST the given body
to uri
sourcepub fn put(uri: impl Into<String>, body: impl IntoBody) -> RequestBuilder
pub fn put(uri: impl Into<String>, body: impl IntoBody) -> RequestBuilder
Creates a RequestBuilder
to PUT the given body
to uri
sourcepub fn patch(uri: impl Into<String>, body: impl IntoBody) -> RequestBuilder
pub fn patch(uri: impl Into<String>, body: impl IntoBody) -> RequestBuilder
Creates a RequestBuilder
to PATCH the resource specified by uri
sourcepub fn delete(uri: impl Into<String>) -> RequestBuilder
pub fn delete(uri: impl Into<String>) -> RequestBuilder
Creates a RequestBuilder
to DELETE the resource specified by uri
sourcepub fn headers(&self) -> impl Iterator<Item = (&str, &HeaderValue)>
pub fn headers(&self) -> impl Iterator<Item = (&str, &HeaderValue)>
The request headers
sourcepub fn header(&self, name: &str) -> Option<&HeaderValue>
pub fn header(&self, name: &str) -> Option<&HeaderValue>
Return a header value
Will return None
if the header does not exist.
sourcepub fn path_and_query(&self) -> Option<&str>
pub fn path_and_query(&self) -> Option<&str>
The request path and query combined
Trait Implementations§
source§impl TryFromIncomingRequest for Request
impl TryFromIncomingRequest for Request
§type Error = IncomingRequestError
type Error = IncomingRequestError
The error if conversion fails
source§fn try_from_incoming_request<'async_trait>(
request: IncomingRequest
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
fn try_from_incoming_request<'async_trait>(
request: IncomingRequest
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
Try to turn the
IncomingRequest
into the implementing typesource§impl TryFromRequest for Request
impl TryFromRequest for Request
§type Error = Infallible
type Error = Infallible
The error if the conversion fails
source§impl TryIntoOutgoingRequest for Request
impl TryIntoOutgoingRequest for Request
§type Error = Infallible
type Error = Infallible
The error if the conversion fails
source§fn try_into_outgoing_request(
self
) -> Result<(OutgoingRequest, Option<Vec<u8>>), Self::Error>
fn try_into_outgoing_request( self ) -> Result<(OutgoingRequest, Option<Vec<u8>>), Self::Error>
Turn the type into an
OutgoingRequest
Read moresource§impl TryIntoRequest for Request
impl TryIntoRequest for Request
§type Error = Infallible
type Error = Infallible
The error if the conversion fails
Auto Trait Implementations§
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