Mountebank Compatibility
Rift implements the Mountebank REST API and configuration format. This allows you to use Rift as a drop-in replacement for Mountebank with significantly better performance.
Core Concepts
Imposters
An imposter is a mock server listening on a specific port. Each imposter:
- Listens on a configurable port
- Handles HTTP or HTTPS protocol
- Contains one or more stubs for request matching
Stubs
A stub defines how to respond to matching requests:
- Predicates: Rules to match incoming requests
- Responses: What to return when predicates match
Predicates
Predicates define request matching criteria:
equals- Exact matchcontains- Partial matchmatches- Regex matchexists- Field existence checkjsonpath- JSON path matchingxpath- XML path matchingand,or,not- Logical combinations
Behaviors
Behaviors modify responses before sending:
wait- Add latencydecorate- Transform response with JavaScriptcopy- Copy request values to responselookup- Look up data from external sources
Quick Example
Create an imposter with multiple stubs:
{
"port": 4545,
"protocol": "http",
"name": "User Service Mock",
"stubs": [
{
"predicates": [{
"equals": { "method": "GET", "path": "/health" }
}],
"responses": [{
"is": { "statusCode": 200, "body": "OK" }
}]
},
{
"predicates": [{
"and": [
{ "equals": { "method": "GET" } },
{ "matches": { "path": "/users/\\d+" } }
]
}],
"responses": [{
"is": {
"statusCode": 200,
"headers": { "Content-Type": "application/json" },
"body": { "id": 1, "name": "User" }
}
}]
},
{
"predicates": [{
"equals": { "method": "POST", "path": "/users" }
}],
"responses": [{
"is": {
"statusCode": 201,
"headers": { "Content-Type": "application/json" },
"body": { "id": 999, "message": "Created" }
},
"_behaviors": {
"wait": 100
}
}]
}
]
}
REST API
Create Imposter
POST /imposters
Content-Type: application/json
{
"port": 4545,
"protocol": "http",
"stubs": [...]
}
List Imposters
GET /imposters
Get Imposter
GET /imposters/{port}
Delete Imposter
DELETE /imposters/{port}
Delete All Imposters
DELETE /imposters
Documentation Sections
- Imposters - Creating and configuring mock servers
- Predicates - Request matching rules
- Responses - Response configuration
- Behaviors - Response modification
- Proxy Mode - Recording and replaying