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
Source§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
Source§impl TryIntoOutgoingRequest for Request
impl TryIntoOutgoingRequest for Request
Source§impl TryIntoRequest for Request
impl TryIntoRequest for Request
Source§type Error = Infallible
type Error = Infallible
The error if the conversion fails
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