Rules
A rule matches a request and applies an action. P05 ships only Map Local; Map Remote, Throttle, Breakpoint, and Edit-Replay ship in P05.5.
Map Local
Serve a local file in place of the upstream response.
Match
- URL pattern — glob with
*wildcards.https://api.example.com/*— any path on that hosthttps://*.example.com/api/*— any subdomain, path under/api/
- Methods — comma-separated list (
GET,POST). Empty = any method. - Flow kinds — restrict to h1/h2/ws/grpc. UI for this lands in P05.5.
Action
- File path — absolute path on your mac. File is read on every request, so edits take effect immediately.
- Status code — defaults to 200.
- Content-Type — explicit override, or sniffed from extension
(
.json→application/json,.html→text/html, etc.).
Behavior
When a request matches a Map Local rule:
- Engine short-circuits — no upstream dial happens.
- Response body is the file’s bytes.
- Response headers include
X-Proxypro-Rule: map-localso you can tell mocked responses apart in the capture list. - The flow is still captured normally — request + response visible in the UI.
Example workflow
You’re building a frontend against an API that’s not deployed yet. The backend team gave you an OpenAPI spec but no server.
- Mock the responses as JSON files under
./mocks/. - Add Map Local rules for
https://api.staging.example.com/users→./mocks/users.jsonand friends. - Run your frontend with
https_proxy=http://127.0.0.1:9090. - Browser sees real responses; backend doesn’t need to exist.
Priority
Rules apply in priority order (lower number = higher priority). First match wins per action type. Drag-reorder ships in P05.5; for now, priority is editable as a number on the rule.
Persistence
P05 keeps rules in-memory only — they vanish on engine restart. SQLite persistence ships in P05.5.
Other actions (shipped)
- Map Remote — rewrite the request URL (scheme + host + path
template). Upstream call still happens, just to a different target.
Supports
responseTransform(regex ops + body template) to rewrite the upstream body before forwarding. - Throttle — token-bucket bandwidth limit + latency injection. Use to reproduce slow-network or timeout bugs.
- Breakpoint — pause matching flows on request and/or response for
live editing in the app. The inspector shows method, URL, headers,
and body; you click Execute (optionally with edits) or Abort.
Engine auto-resumes with originals after 30 seconds, and bypasses
silently when the app isn’t running (so headless deployments don’t
hang). Persisted bytes are the edited bytes —
was_breakpoint_editedon the Flow flags tampered rows for MCP / replay consumers. - Mock State Write — mutate a shared mock state on request match
(typically
POST /claim). REPLACE or RFC 7396 JSON_MERGE; patch is a Go template. - Edit-Replay — right-click any captured flow → mutate → re-send.
The protobuf schema for all of these lives in
proto/engine.proto.