API Mocking Gateway & Traffic Recorder
Mirage is a powerful HTTP/HTTPS proxy server designed for local development and testing. It intercepts API requests, allowing you to mock responses, simulate network conditions, and record traffic for replay.
- π Request Mocking - Define scenarios to return custom responses
- π Traffic Recording - Capture and replay real API interactions
- π― Pattern Matching - Match by path (glob), method, and headers
- β±οΈ Latency Simulation - Add delays to simulate slow networks
- π Scenario Switching - Toggle mocks on/off in real-time
- π Web Dashboard - Monitor requests with a clean UI
- π Zero Dependencies - Single binary, cross-platform
- β‘ High Performance - Built with Go for speed and concurrency
brew install comethrusws/mirage/miragecurl -sL https://raw.githubusercontent.com/comethrusws/mirage/main/install.sh | bashgo install github.com/comethrusws/mirage/cmd/mirage@latestDownload the latest release from GitHub Releases.
git clone https://github.com/comethrusws/mirage.git
cd mirage
make build
sudo make installmirage startDashboard available at http://localhost:8080/__mirage/
mirage start --config examples/config.yamlmirage record --output traffic.jsonmirage replay traffic.jsonCreate a YAML file to define mock scenarios:
scenarios:
- name: success-response
match:
path: /api/users
method: GET
response:
status: 200
headers:
Content-Type: application/json
body: |
{
"users": [
{"id": 1, "name": "Alice"},
{"id": 2, "name": "Bob"}
]
}
delay: 100ms
- name: server-error
match:
path: /api/*
headers:
X-Test-Error: "true"
response:
status: 500
body: "Internal Server Error"
delay: 2s
- name: not-found
match:
path: /api/missing
method: POST
response:
status: 404
body: '{"error": "Not found"}'- Path: Supports glob patterns (
/api/*,/users/*/profile) - Method: GET, POST, PUT, DELETE, PATCH, etc.
- Headers: Match specific header values
mirage start --config dev-api.yaml --port 8080Configure your app to proxy through http://localhost:8080
mirage scenarios list config.yamlToggle scenarios via the dashboard or CLI.
mirage record --output prod-traffic.jsonLater replay for testing:
mirage replay prod-traffic.jsonAccess the web dashboard at http://localhost:8080/__mirage/
Features:
- Real-time request log
- Scenario management (enable/disable)
- Request/response details
- Performance metrics
mirage start [flags] Start proxy server
mirage record [flags] Record traffic mode
mirage replay <file> Replay recorded traffic
mirage scenarios list <config> List scenarios in config
-p, --port int Port to run on (default 8080)
-c, --config string Path to config file
-o, --output string Output file for recordings
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β β β β β β
β Your App ββββββββββΆβ Mirage ββββββββββΆβ Real API β
β β β β β β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β
β
βββββββΌββββββ
β Dashboard β
β Recorder β
β Scenarios β
βββββββββββββ
- API Development - Mock external APIs during development
- Testing - Simulate error conditions and edge cases
- Integration Testing - Record production traffic for test suites
- Network Simulation - Test app behavior with slow/unreliable connections
- Debugging - Inspect and modify API requests/responses in real-time
Contributions are welcome! Please read CONTRIBUTING.md for guidelines.
For security concerns, see SECURITY.md.
MIT License - see LICENSE for details.
Built with β€οΈ using:
- Cobra - CLI framework
- Gorilla Mux - HTTP routing
- YAML v3 - Configuration parsing
β Star the project if you find it useful!