Skip to main content

Crate philiprehberger_mock_server

Crate philiprehberger_mock_server 

Source
Expand description

Lightweight, per-test HTTP mock server for testing API integrations.

Spins up a real TCP server on a random port using raw tokio TCP — no external HTTP framework required. Each test gets its own isolated server instance.

§Example

use philiprehberger_mock_server::{MockServer, Method};

#[tokio::main]
async fn main() {
    let server = MockServer::start().await;

    server
        .mock(Method::GET, "/hello")
        .with_status(200)
        .with_body("world")
        .create();

    println!("Mock server running at {}", server.url());
}

Structs§

MockBuilder
Fluent builder for configuring a mock response.
MockServer
A lightweight HTTP mock server bound to a random local port.
RecordedRequest
A recorded incoming HTTP request.

Enums§

Method
HTTP method for mock matching.