pub struct Request { /* private fields */ }Expand description
A request as it was sent, with its final URL, headers, body, and files.
Fakes receive it, and they record it for assertions.
Implementations§
Source§impl Request
impl Request
Sourcepub fn url(&self) -> &str
pub fn url(&self) -> &str
The full URL, with the base URL, placeholders, and query parameters applied.
Sourcepub fn header(&self, name: &str) -> Option<&str>
pub fn header(&self, name: &str) -> Option<&str>
A header’s value, if the request sent the header and its value is text.
Sourcepub fn has_header(&self, name: &str, value: &str) -> bool
pub fn has_header(&self, name: &str, value: &str) -> bool
Whether the request sent the header with exactly this value.
Sourcepub fn headers(&self) -> &HeaderMap
pub fn headers(&self) -> &HeaderMap
Every header the request sent, including the client’s User-Agent.
Sourcepub fn json<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
pub fn json<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
Sourcepub fn data(&self) -> Value
pub fn data(&self) -> Value
The data of a JSON or form body, including a multipart form’s text fields, for quick checks in assertions.
Returns Value::Null when the request has no body, or when the body isn’t JSON or a
form. A form’s fields come back as strings.
request.data()["name"] == "Taylor"Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Request
impl Forget for Request
impl Move for Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnsafeUnpin for Requestwhere
*const [u8] is !null: UnsafeUnpin,
PhantomData<[u8]>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const [Pos] is !null: UnsafeUnpin,
PhantomData<[Pos]>: UnsafeUnpin,
PhantomData<Bucket<HeaderValue>>: UnsafeUnpin,
PhantomData<ExtraValue<HeaderValue>>: UnsafeUnpin,
*const u8: UnsafeUnpin,
Align8<*mut ()>: UnsafeUnpin,
&'static Vtable: UnsafeUnpin,
PhantomData<(String, String)>: UnsafeUnpin,
PhantomData<SentFile>: UnsafeUnpin,
impl UnwindSafe for Requestwhere
BoxRaw<[u8]>: UnwindSafe,
RawVecInner: UnwindSafe,
BoxRaw<[Pos]>: UnwindSafe,
*const u8: UnwindSafe,
Align8<*mut ()>: UnwindSafe,
&'static Vtable: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<K> ForeignKey<K> for K
impl<K> ForeignKey<K> for K
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.