Skip to content

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 host
    • https://*.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 (.jsonapplication/json, .htmltext/html, etc.).

Behavior

When a request matches a Map Local rule:

  1. Engine short-circuits — no upstream dial happens.
  2. Response body is the file’s bytes.
  3. Response headers include X-Proxypro-Rule: map-local so you can tell mocked responses apart in the capture list.
  4. 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.

  1. Mock the responses as JSON files under ./mocks/.
  2. Add Map Local rules for https://api.staging.example.com/users./mocks/users.json and friends.
  3. Run your frontend with https_proxy=http://127.0.0.1:9090.
  4. 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.

Future actions (P05.5)

  • Map Remote — rewrite the request URL (scheme + host + path template). Upstream call still happens, just to a different target.
  • Throttle — token-bucket bandwidth limit + latency injection.
  • Breakpoint — pause the request, push to the UI for inspection + editing, then resume.
  • Edit-Replay — right-click any captured flow → mutate → re-send.

The protobuf schema for all four already lives in proto/engine.proto.