#[non_exhaustive]pub struct CapturedRequest {
pub method: String,
pub path: String,
pub body: String,
pub outcome: RequestOutcome,
pub matched_scenario: Option<String>,
pub capture_id: u64,
pub status_code: u16,
pub timestamp: Instant,
}Expand description
A captured HTTP request for test assertions.
Available via MockServer::get_requests() after requests have been
handled. The struct is #[non_exhaustive] so future versions may add
new fields (e.g. captured response status) without a semver break —
prefer the builder-free accessors over exhaustive destructuring.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.method: StringHTTP method (always POST for LLM endpoints, GET for /code/).
path: StringResolved request path — for Gemini, the real
/v1beta/models/{model}:{action} the client used, not the router
wildcard pattern.
body: StringRaw request body as received on the wire. Present for Matched,
NoFixtureMatch, and BadRequest outcomes. Empty for
AuthRejected (the auth middleware does not buffer the body to
stay off the hot path) and CodeEndpoint (GET has no body).
outcome: RequestOutcomeWhat the server decided about this request. See RequestOutcome.
matched_scenario: Option<String>Name of the matched fixture’s scenario, if any. Always None for
non-Matched outcomes.
capture_id: u64Monotonic capture ID for consistent ordering across the
/ui/requests snapshot and the live SSE feed.
status_code: u16HTTP status code the server returned (or will return) for this
request. Determined at capture time from the matched fixture:
error.status for error fixtures, 400 for streaming+refusal,
200 for normal responses, 404 for no-match, etc.
timestamp: InstantTimestamp when the request was received.
Implementations§
Source§impl CapturedRequest
impl CapturedRequest
Sourcepub fn was_matched(&self) -> bool
pub fn was_matched(&self) -> bool
true when a fixture was selected for this request — the server
matched and dispatched it, regardless of the resulting HTTP
status. Use this for the common test assertion “my client retry
path actually hit a matched fixture after the 429”. See
RequestOutcome::Matched for the full list of cases that
count as matched.
Trait Implementations§
Source§impl Clone for CapturedRequest
impl Clone for CapturedRequest
Source§fn clone(&self) -> CapturedRequest
fn clone(&self) -> CapturedRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more