Skip to main content

Mock HTTP Server (rumour mock)

The rumour mock command provides a built-in, lightning-fast HTTP mock server specifically designed for localized API development, testing, and CI/CD automation.

When developing integration test suites or building frontend applications, teams often hit friction:

  • Upstream backend services or third-party APIs (Stripe, Twilio, OAuth providers) may be unstable, rate-limited, or unavailable in local development.
  • Running destructive end-to-end tests (such as deleting customer records or triggering real payment charges) against shared staging or production environments carries risk.
  • CI/CD pipelines need fully hermetic, reproducible, network-isolated environments that boot in milliseconds without spinning up bulky external microservices.

rumour mock addresses this by embedding a high-concurrency Axum-based HTTP mock engine directly into the Rumour CLI. It operates completely offline, supports dynamic variable templating, allows on-the-fly scenario overrides via custom headers, and can act as an intercepting reverse proxy that records live traffic and scaffolds test suites automatically.


Architecture & Operational Modes​

rumour mock operates across three primary workflows depending on whether you are recording real traffic, serving pre-compiled offline mocks, or launching directly from request files:

Mode 1: Intercept & Record Mode (rumour mock intercept)​

In this mode, Rumour acts as an intelligent reverse proxy between your application and a live backend. It forwards requests upstream, transparently captures real responses into mock.manifest.json, and auto-scaffolds executable .toml test files with auto-generated assertions:

Mode 2: Compile & Serve Mode (rumour mock compile + start)​

In this mode, Rumour pre-compiles all .toml requests in your collection into mock.manifest.json. The mock server boots instantly offline with sub-millisecond responses without requiring network access or external services:

Mode 3: Direct Runtime (rumour mock [PATH])​

When running rumour mock [PATH] without a subcommand, Rumour reads your .toml files directly, builds synthetic routes in-memory, and immediately begins serving mock endpoints on the configured port.


1. Compiling Mock Manifests (compile)​

Before starting the standalone server, you can compile your workspace TOML request files into a declarative, editable manifest file (mock.manifest.json).

rumour mock compile [PATH] [OPTIONS]

Aliases: rumour mock init, rumour mock build

Command Options​

OptionFlagDefaultDescription
[PATH]Argument.Directory containing TOML requests or single request file to scan.
--output-omock.manifest.jsonPath where the compiled manifest file will be written.
--use-fixtures—falseUse recorded fixtures/snapshots for response bodies if available.
--fixture-dir-S.rumour/snapshotsCustom directory containing recorded fixture JSON files.
--yes-yfalseOverwrite an existing manifest file without prompting.

How Response Synthesis Works​

When compiling TOML files into mock endpoints, Rumour deterministically synthesizes realistic JSON response bodies using a four-tier priority hierarchy:

  1. Explicit Body ([body]): If the TOML file defines a raw JSON body in its [body] block, that payload is preserved.
  2. Assertion Reverse-Engineering ([assert.json]): Rumour inspects your JSON assertions. If you assert equal, contains, greater_than, or less_than, Rumour reverse-engineers a matching JSON object satisfying those constraints. For other assertion keys, it maps field names to plausible synthetic values (names, emails, dates).
  3. Extractable Variables ([extract]): If the request extracts dynamic tokens (e.g. auth_token = "$.token"), Rumour ensures those keys exist in the generated mock payload.
  4. Method-Based Defaults: If no assertions or body exist, Rumour falls back to standard RESTful payloads based on HTTP method:
    • POST / PUT $\rightarrow$ {"id": "<uuid>", "status": "ok", "created": true} (HTTP 201)
    • PATCH $\rightarrow$ {"status": "ok", "updated": true} (HTTP 200)
    • DELETE $\rightarrow$ {"deleted": true, "status": "ok"} (HTTP 204)
    • GET / Other $\rightarrow$ {"status": "ok", "message": "Mock response"} (HTTP 200)

Example Compilation​

rumour mock compile ./collections -o mock.manifest.json

Terminal Output:

⚙ Scanning TOML requests in ./collections...

╔══════════════════════════════════════════════════════════╗
║ rumour mock init — compilation ║
╚══════════════════════════════════════════════════════════╝
Manifest → mock.manifest.json
Source → ./collections
Status → 3 routes compiled

┌───────────────────────────────────────────────────────────────┐
│ METHOD PATH PATTERN STATUS SOURCE FILE │
╞═══════════════════════════════════════════════════════════════╡
│ GET /api/v1/users/:id 200 users/get_user.toml │
│ POST /api/v1/users 201 users/create_user.toml │
│ DELETE /api/v1/users/:id 204 users/delete_user.toml │
└───────────────────────────────────────────────────────────────┘

✓ Generated mock.manifest.json
ℹ Run rumour mock start to start serving these mock endpoints.

Manifest File Format (Schema v2)​

Rumour generates Schema v2 manifests structured around multi-server configurations. Routes are organized under server definitions (by default under "default"):

{
"version": 2,
"generated_at": "2026-09-09T11:13:23Z",
"source_path": "./collections",
"servers": {
"default": {
"id": "default",
"name": "Default Server",
"protocol": "http",
"host": "127.0.0.1",
"port": 8080,
"routes": [
{
"method": "GET",
"path_pattern": "/api/v1/users/:id",
"protocol": "http",
"status": 200,
"response_headers": {
"content-type": "application/json"
},
"response_body": "{\"id\": \"{{id}}\", \"name\": \"User {{id}}\"}",
"source_file": "users/get_user.toml",
"source_mtime": 1725880403
}
]
}
}
}
Backwards Compatibility

Rumour remains fully backwards-compatible with legacy Schema v1 manifests (where routes: [] was at the top level). When loading a v1 manifest, Rumour automatically wraps existing routes under the default server configuration in-memory.


2. Starting the Mock Server (start)​

Once a manifest exists, start the HTTP server:

rumour mock start [PATH] [OPTIONS]

Command Options​

OptionFlagDefaultDescription
[PATH]Argument.Workspace root or path to the manifest file.
--port-p8080Port to bind to (overrides settings).
--host-H127.0.0.1IP address to bind to (use 0.0.0.0 for Docker/network exposure).
--delay—0Artificial response latency in milliseconds to simulate network lag.
--cors-origin—*Access-Control-Allow-Origin value (allows all web clients by default).
--verbose-vfalseEnable detailed per-request logging (payloads, headers, matched routes).
--watch-wfalseWatch mock.manifest.json for changes and hot-reload routes without restart.
--proxy—NoneUpstream fallback URL for unmocked routes (e.g. https://api.example.com).
--capture—falseAutomatically capture proxied upstream responses into mock.manifest.json.
--passthrough-PfalseForce proxying all requests upstream even if a matching mock route exists.
--save-toml—requestsAuto-scaffold .toml test files with assertions for captured traffic.
--daemon-dfalseDetach and run the server in the background as a background daemon.

Running in Daemon Mode for CI/CD​

When executing automated test suites, use -d / --daemon to avoid blocking your shell or CI workflow step:

# 1. Start mock server in background
rumour mock start . -d -p 8080

# 2. Run your integration tests against http://127.0.0.1:8080
rumour run ./tests -V base_url=http://127.0.0.1:8080

# 3. Stop the background mock server
rumour mock stop .

3. Live Traffic Interception (intercept)​

rumour mock intercept launches Rumour as an intelligent reverse proxy between your application and a live backend. Every request and response passing through is captured, recorded, and automatically scaffolded into test files.

rumour mock intercept <TARGET> [PATH] [OPTIONS]

Alias: rumour mock capture

Example Usage​

rumour mock intercept https://api.stripe.com . --port 8080 --save-toml ./recorded_tests -v

What Happens During Interception:​

  1. Proxying: Rumour binds to http://127.0.0.1:8080 and proxies incoming requests to https://api.stripe.com.
  2. Manifest Generation: Requests and responses are written directly into mock.manifest.json.
  3. Automated Test Scaffolding: With --save-toml ./recorded_tests, Rumour creates fully functional .toml request files with automatically derived [assert] blocks for status code, headers, and JSON structure.

4. Server Lifecycle & Monitoring​

Rumour provides dedicated commands to monitor, inspect, and manage the mock server process:

Checking Server Status (status)​

Displays the server health, running PID, port binding, and synchronization state against the underlying TOML files:

rumour mock status .
╔══════════════════════════════════════════════════════════╗
║ rumour mock status ║
╚══════════════════════════════════════════════════════════╝
Manifest → ./mock.manifest.json (v2)
Last Built → 2026-09-09T11:13:23Z
Source Path → .
Routes → 4 endpoints compiled
Server Status → Active ● (http://127.0.0.1:8080 · PID: 1216456)
Sync Status → Up to date with all TOML request files

Mock Settings (from rumour.settings.json):
• Default Port : 8080
• Default Host : 127.0.0.1
• Delay : 0ms
• CORS Origin : *
• Hot-reload : disabled

Listing Compiled Routes (list)​

Inspect all endpoints configured in mock.manifest.json:

# Standard table view
rumour mock list .

# Detailed view showing bodies, headers, and scenarios
rumour mock list . -d

# Machine-readable JSON output
rumour mock list . --json

Aliases: rumour mock routes, rumour mock endpoints

Real-Time Traffic Logs (logs)​

Stream or filter incoming HTTP traffic hitting the mock server:

# Stream live incoming requests (similar to tail -f)
rumour mock logs . -f

# Filter for failed requests only (HTTP 500)
rumour mock logs . -s 500

# Filter by HTTP method
rumour mock logs . -m POST

# Clear the mock traffic log file (.rumour/mock.log)
rumour mock logs . --clear

Aliases: rumour mock inspector, rumour mock tail, rumour mock traffic

Incremental Route Updating (update)​

If you modify, add, or delete .toml files in your workspace, you do not need to recompile the entire manifest from scratch. Running rumour mock update performs an incremental diff, updating only altered endpoints while preserving custom response scenarios:

rumour mock update .

Stopping and Restarting (stop / restart)​

# Graceful stop
rumour mock stop .

# Force termination (SIGKILL)
rumour mock stop . -f

# Restart daemon with new settings
rumour mock restart . -p 9000 -d

5. Dynamic Mocking & Scenario Overrides​

Rumour supports advanced mock features that eliminate static, hard-coded mock data.

Dynamic Path & Query Variable Resolution​

Path parameters (e.g. /users/:id) and query parameters (e.g. ?tenant=acme) are extracted on every incoming request and made available as template variables within the mock response body and response headers:

{
"method": "GET",
"path_pattern": "/api/users/:id",
"status": 200,
"response_headers": {
"content-type": "application/json",
"x-requested-user": "{{id}}"
},
"response_body": "{\"id\": \"{{id}}\", \"name\": \"User {{id}}\", \"tenant\": \"{{tenant}}\"}"
}

When a request arrives at GET /api/users/42?tenant=alpha, the mock server dynamically returns:

{
"id": "42",
"name": "User 42",
"tenant": "alpha"
}

Dynamic Faker Tokens​

Response bodies and headers support built-in dynamic faker tokens:

  • {{$guid}} or {{$uuid}}: Generates a unique UUID v4.
  • {{$timestamp}}: Current Unix epoch timestamp in seconds.
  • {{$isoTimestamp}}: Current ISO 8601 UTC timestamp.
  • {{$randomInt}}: Random integer between 1 and 1000.

Dynamic Scenario Switching via Control Headers​

You can define multiple named response scenarios for a single route inside mock.manifest.json:

{
"method": "POST",
"path_pattern": "/auth/login",
"status": 200,
"response_body": "{\"token\": \"jwt-valid-token\"}",
"responses": [
{
"name": "Invalid Credentials",
"status": 401,
"headers": { "content-type": "application/json" },
"body": "{\"error\": \"Unauthorized\", \"message\": \"Invalid username or password\"}"
},
{
"name": "Account Locked",
"status": 423,
"headers": { "content-type": "application/json" },
"body": "{\"error\": \"Locked\", \"retry_after\": 300}"
}
]
}

Clients or test suites can trigger specific scenarios on demand using custom request headers:

HeaderDescriptionExample
x-rumour-scenario or x-mock-scenarioSelect a named scenario case-insensitivelyx-rumour-scenario: Invalid Credentials
x-rumour-status or x-mock-statusOverride the HTTP response status codex-rumour-status: 404
x-rumour-delay or x-mock-delayInject artificial delay (ms) for this requestx-rumour-delay: 2000

6. Interactive Web Dashboard & Admin API​

The mock server includes an interactive Web UI dashboard and built-in administration API.

Web Dashboard​

Navigate to http://127.0.0.1:8080/__rumour in your web browser (or GET / if no mock route is bound to root). The dashboard displays:

  • Active endpoints and route matching patterns
  • Real-time route hit counters
  • Traffic inspector streaming recent request/response headers, bodies, and latencies

Internal Admin Endpoints​

The mock server exposes built-in administration endpoints under /__rumour/*:

EndpointMethodDescription
/__rumour/healthGETHealth check returning status, loaded route count, and default delay.
/__rumour/routesGETReturns JSON array of all active routes with real-time hit counts.
/__rumour/resetPOSTResets all route hit counters to zero.
/__rumour/trafficGET / DELETEView in-memory circular traffic buffer (GET) or clear history (DELETE).
/__rumour/shutdownPOSTRemotely triggers a graceful server shutdown.
Admin Authentication

If an admin_token is configured in rumour.settings.json, requests to mutating admin endpoints (/reset, /traffic deletion, /shutdown) require authentication via Authorization: Bearer <token>, X-Admin-Token: <token>, or ?token=<token>.


7. Workspace Configuration (rumour.settings.json)​

You can set persistent mock defaults in your workspace's rumour.settings.json file:

{
"mock": {
"port": 8080,
"host": "127.0.0.1",
"delay_ms": 0,
"cors_origin": "*",
"verbose": false,
"watch": true,
"source_path": ".",
"manifest_file": "mock.manifest.json",
"snapshots": {
"enabled": false,
"directory": ".rumour/snapshots"
},
"proxy": "https://staging-api.example.com",
"save_toml": "requests"
}
}