Getting Started
Conditional Matching
A route doesn't have to return the same thing every time. Add match conditions to a route and MockBase only returns that route's response when the incoming request satisfies all of them — otherwise it moves on to the next candidate route for that method and path.
Adding a condition
Each condition has three parts:
- Source — where to look:
query,header, orbody. - Key — the parameter/header name, or a dot-path into the JSON body (e.g.
user.emailreaches a nested field). Header lookups are case-insensitive. - Operator —
equals,not_equals,contains,exists, orregex.
A route can have multiple conditions; all of them must pass for that route to match.
Which route wins
When more than one route could match the same method and path:
- Routes are tried in order of priority (higher number first).
- Routes with equal priority are tried in the order you added them.
- The first route whose conditions all pass — or that has no conditions at all — is the one that responds.
A route with no conditions always passes, so give it the lowest priority among its siblings if you want it to act as a catch-all fallback after more specific, conditioned routes.
No match
If no route for a method and path matches, MockBase returns 404 with {"error": "route_not_found"} — unless Record & Replay is configured for the mock, in which case the request is proxied to your upstream instead.
Example
GET /users with two routes:
| Priority | Condition | Response |
|---|---|---|
| 10 | header X-Env equals staging | a staging-flavored payload |
| 0 | (none) | the normal payload |
A request with X-Env: staging gets the first route; every other request falls through to the unconditioned one.