Skip to main content

Crate mockserver_client

Crate mockserver_client 

Source
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§

ClientBuilder
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.
ForwardChainExpectation
Fluent builder for creating an expectation via client.when(...).respond(...).
HttpError
Error action — return a connection-level error to the caller.
HttpForward
Forward action — proxy the matched request to another host.
HttpRequest
Matcher for an HTTP request. Uses builder methods for fluent construction.
HttpResponse
Builder for an HTTP response action.
MockServerClient
A blocking client for the MockServer control-plane REST API.
Ports
Port list (used by status and bind endpoints).
TimeToLive
How long an expectation remains active.
Times
How many times an expectation should be matched.
Verification
A verification request sent to MockServer.
VerificationSequence
A verification sequence request.
VerificationTimes
Verification constraints — how many times a request must have been received.

Enums§

Body
Request/response body — either a plain string or a typed object.
ClearType
The type of data to clear from MockServer.
Error
Errors returned by the MockServer client.
RetrieveFormat
The response format for retrieve calls.
RetrieveType
The type of data to retrieve from MockServer.

Type Aliases§

Result
Result type alias using Error.