Skip to content

fa33az/wiremocker

Repository files navigation

WireMocker Logo

A blazing-fast, dynamic HTTP Mock Server built with Rust and Axum, featuring zero-downtime hot-reloading and a beautiful built-in dashboard.

Rust License


Overview

WireMocker is an API Mock Server designed for Frontend Developers, Mobile Developers, QA Engineers, and Backend Developers. It allows you to dynamically create HTTP endpoints using a simple YAML configuration file without writing a single line of code.

Key Features

  • Blazing Fast: Built on top of Rust, Tokio, and Axum for maximum performance and low latency.
  • Hot Reloading: Automatically detects changes in your mock.yaml configuration and updates endpoints instantly with zero downtime.
  • Built-in Dashboard: Comes with a beautiful, monochrome-styled UI to monitor your endpoints, view live request logs, and edit your configuration in real-time.
  • Dynamic Data: Generate fake data on the fly using Handlebars-like syntax (e.g., {{name}}, {{uuid}}, {{email}}).
  • Delay Simulation: Easily mock slow network conditions by injecting artificial latency.
  • Error Simulation: Randomly drop requests to simulate flaky networks using the error_rate property.
  • Sequential Responses: Define a sequence of different responses for the same endpoint that will loop sequentially upon multiple requests.

Architecture

graph TD
    subgraph Client
        UI[WireMocker Dashboard UI]
        API[API Consumer / Frontend]
    end

    subgraph WireMocker Server
        Axum[Axum Router]
        DashboardHandler[Dashboard & Log Handlers]
        MockHandler[Dynamic Mock Handlers]
        State[Shared Application State]
        
        subgraph Hot Reload System
            Notify[File Watcher]
            ConfigLoader[YAML/JSON Parser]
        end
    end

    API -->|HTTP Requests| Axum
    UI -->|API & WebSocket| Axum
    
    Axum --> DashboardHandler
    Axum --> MockHandler
    
    DashboardHandler <--> State
    MockHandler <--> State
    
    Notify -->|File Changed Event| ConfigLoader
    ConfigLoader -->|Updates Endpoints| State
Loading

Installation & Usage

1. Build from Source

Ensure you have Rust and Cargo installed, then clone the repository:

git clone https://github.com/fa33az/wiremocker.git
cd wiremocker
cargo build --release

2. Run the Server

Run the compiled binary and specify the path to your mock configuration file:

./target/release/wiremocker serve configs/mock.yaml

If you are running in a development environment, you can simply use:

cargo run -- serve configs/mock.yaml

The server will start by default on http://localhost:8080.

3. Access the Dashboard

Open your browser and navigate to the built-in UI: 👉 http://localhost:8080/__wiremocker/ui


Configuration (mock.yaml)

WireMocker endpoints are defined entirely via a configuration file (YAML or JSON).

Here is an example of mock.yaml:

server:
  port: 8080

routes:
  # Basic GET Request
  - path: /users
    method: GET
    response:
      status: 200
      body:
        message: "Hello from WireMocker!"
      headers:
        Content-Type: application/json

  # Path Parameters
  - path: /users/{id}
    method: GET
    response:
      status: 200
      body:
        id: "{id}"
        name: "User {id}"

  # Dynamic Fake Data & Delay
  - path: /faker
    method: GET
    response:
      status: 200
      delay: 500
      body:
        uuid: "{{uuid}}"
        username: "{{name}}"
        email: "{{email}}"
        company: "{{company}}"

  # Simulate Flaky Network (20% failure rate)
  - path: /flaky
    method: GET
    response:
      status: 200
      error_rate: 0.2
      body:
        status: "success"

  # Sequential Responses (Loops through the array)
  - path: /sequence
    method: GET
    response:
      strategy: sequential
      options:
        - status: 200
          body: { step: 1 }
        - status: 201
          body: { step: 2 }
        - status: 400
          body: { error: "Failed on step 3" }

When you save changes to mock.yaml, WireMocker will automatically detect the file change and update the endpoints instantly without requiring a server restart.


License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Built with by fa33az

About

A blazing-fast, dynamic HTTP mock server built with Rust and Axum. Features zero-downtime hot-reloading, a monochrome dashboard UI, dynamic fake data generation, and network latency simulation.

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors