Expand description
§mockserver-client
An idiomatic Rust client for MockServer’s control-plane REST API.
This crate provides a blocking (synchronous) client that communicates with a running MockServer instance over HTTP. It supports creating expectations, verifying requests, clearing/resetting state, and retrieving recorded data.
§Quick Start
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse};
let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.when(HttpRequest::new().method("GET").path("/hello"))
.respond(HttpResponse::new().status_code(200).body("world"))
.unwrap();
client.verify(
HttpRequest::new().path("/hello"),
mockserver_client::VerificationTimes::at_least(1),
).unwrap();
client.reset().unwrap();Re-exports§
pub use breakpoint::phase;pub use breakpoint::BreakpointMatcherRegistration;pub use breakpoint::BreakpointMatcherResponse;pub use breakpoint::BreakpointMatcherEntry;pub use breakpoint::BreakpointMatcherList;pub use breakpoint::PausedStreamFrame;pub use breakpoint::StreamFrameDecision;pub use breakpoint::WsEnvelope;pub use breakpoint::BreakpointRequestHandler;pub use breakpoint::BreakpointResponseHandler;pub use breakpoint::BreakpointStreamFrameHandler;pub use breakpoint::extract_header;pub use breakpoint::set_header;pub use breakpoint::route_request;pub use breakpoint::route_response;pub use breakpoint::route_stream_frame;
Modules§
- breakpoint
- Breakpoint matcher registration, callback WebSocket client, and handler routing.
- launcher
- On-demand binary launcher for MockServer.
Structs§
- Client
Builder - Builder for constructing a
MockServerClient. - Delay
- A time delay (e.g., for response delays).
- Expectation
- A full expectation combining a request matcher with an action.
- Forward
Chain Expectation - Fluent builder for creating an expectation via
client.when(...).respond(...). - Http
Error - Error action — return a connection-level error to the caller.
- Http
Forward - Forward action — proxy the matched request to another host.
- Http
Request - Matcher for an HTTP request. Uses builder methods for fluent construction.
- Http
Response - Builder for an HTTP response action.
- Mock
Server Client - A blocking client for the MockServer control-plane REST API.
- Ports
- Port list (used by status and bind endpoints).
- Time
ToLive - How long an expectation remains active.
- Times
- How many times an expectation should be matched.
- Verification
- A verification request sent to MockServer.
- Verification
Sequence - A verification sequence request.
- Verification
Times - Verification constraints — how many times a request must have been received.
Enums§
- Body
- Request/response body — either a plain string or a typed object.
- Clear
Type - The type of data to clear from MockServer.
- Error
- Errors returned by the MockServer client.
- Retrieve
Format - The response format for retrieve calls.
- Retrieve
Type - The type of data to retrieve from MockServer.