A high-performance, configuration-driven Mock Server built in Rust.
keva-mock is designed to simulate complex backend systems, third-party services (e.g., Payment Gateways, ERPs), and internal microservices. It focuses on Developer Experience, Performance, and Correctness.
- Multi-Tenant Workspaces: Run multiple isolated mock environments (e.g.,
/stripe,/transferwise) on a single server instance. - Dynamic Routing: zero-copy path matching with support for wildcard and parameterized routes.
- Strict Schema Validation: Validate incoming requests (Body, Query, Headers) and outgoing responses against defined schemas (JSON Schema / TOML).
- Scripting Hooks (Rhai): Attach dynamic logic (
onRequest,onResponse) using Rhai - a safe, embedded scripting language for Rust. - Scheduled Jobs: Native Cron support to trigger webhooks or internal actions.
- Chaos Engineering: Built-in support for simulating Latency, Timeouts, and Errors via headers.
- Vertical Slice Architecture: Codebase organized by Functional Capability for maintainability.
# Clone the repository
git clone https://github.com/kevalabs/keva-mock.git
# Build via Cargo
cargo build --release
# Run
./target/release/keva-mock --server-config server.tomlkeva-mock uses a hierarchical configuration system.
Defines the listener and workspace mappings.
[server]
port = 3000
host = "0.0.0.0"
[workspaces]
# Mount workspaces to context roots
"/stripe" = "./mocks/stripe"
"/transferwise" = "./mocks/transferwise"Defines the behavior for a specific domain.
root = "/stripe"
[database]
url = "postgres://user:pass@localhost:5432/stripe_mock"
[[endpoints]]
path = "/v1/payment/initiate"
method = "POST"
[endpoints.request]
schema_file = "schemas/initiate_req.toml"
[endpoints.response]
source = "file"
file = "data/success_response.toml"
# Or use a script for dynamic logic
# source = "script"
# script_file = "scripts/initiate_payment.rhai"keva-mock follows a Vertical Slice Architecture to keep related logic (Routing, Validation, Mocking) co-located.
- Core: Async Request Pipeline built on
AxumandTokio. - Engine:
Rhaiscripting engine for dynamic behavior without recompilation. - Storage:
SQLxfor DB interaction andRedisfor distributed state (e.g., Rate Limiting).
- Fork the repo.
- Create a feature branch (
git checkout -b feature/amazing-feature). - Commit your changes.
- Open a Pull Request.
MIT