A lightweight, self-hosted HTTP mock server designed to run in Kubernetes.
It serves both the Mock Engine and the Management UI/API on a single port.
The service runs as a StatefulSet with a PersistentVolumeClaim per pod.
Mocks are stored in an SQLite database on the PVC.
Why:
- Mocks can be added, updated, and deleted at runtime without any redeployment.
- SQLite is a single binary dependency with zero network overhead.
- WAL mode makes concurrent reads + writes safe.
- Easy to back up (
sqlite3 mocks.db .dump > backup.sql). - Scales to a single-pod "always on" mock service that teams in the cluster share.
- Go 1.22+
- C-Compiler (for SQLite/CGO) or use
CGO_ENABLED=0(though CGO is recommended for performance)
make run
# UI & Management API → http://localhost:8080/ui
# Mock Server catch-all → http://localhost:8080/*go run ./cmd/server/main.gogo build ./cmd/server/main.goOpen your browser at http://localhost:8080/ui.
POST /api/mocks
Content-Type: application/json
{
"name": "Get user",
"method": "GET",
"path": "/api/users/{id}",
"status_code": 200,
"resp_headers": { "Content-Type": "application/json" },
"resp_body": "{\"id\": 42, \"name\": \"Alice\"}",
"priority": 10
}| Pattern | Matches |
|---|---|
/api/users |
exactly /api/users |
/api/users/{id} |
/api/users/123, /api/users/abc |
/api/** |
anything under /api/ |
* (method) |
any HTTP method |
Higher priority integers are evaluated first. Default is 0.
Use this when multiple mocks could match the same path.
| Env var | Flag | Default | Description |
|---|---|---|---|
ADDR |
-addr |
:8080 |
Server listen address |
DB_PATH |
-db |
/data/mocks.db |
SQLite database path |
LOG_LEVEL |
-log-level |
info |
debug, info, warn, error |
.
├── cmd/server/main.go # Entry point, wires handlers together
├── internal/
│ ├── model/mock.go # Domain types
│ ├── store/sqlite.go # SQLite persistence
│ └── handler/
│ ├── handler.go # Management API handlers
│ ├── matcher.go # Mock matching logic
│ └── ui.go # Embedded Management UI
├── k8s/httpmock.yaml # Kubernetes Deployment
├── Dockerfile
└── Makefile