Interception & Rewriting Capabilities
This page lists every built-in traffic-rewriting capability in RelayCore, with a minimal JSON example for each (ready to feed to PUT /api/v1/rules or relay-core-cli rules validate). For the full filter schema see Rule API.
Mock Response
Replace the upstream response with a local fake. Use for frontend development, contract testing, error simulation.
{
"id": "mock-health",
"name": "Mock /v1/health",
"filter": { "path": "/v1/health" },
"action": {
"type": "MockResponse",
"status": 200,
"headers": { "content-type": "application/json" },
"body": { "type": "Text", "value": "{\"ok\":true}" }
},
"enabled": true
} Map Local
Serve a local file in place of an HTTP request. Use for frontend offline dev.
{
"id": "map-local-static",
"name": "Serve /static from disk",
"filter": { "path_starts_with": "/static/" },
"action": {
"type": "MapLocal",
"path": "/Users/me/projects/app/static",
"content_type": null
},
"enabled": true
} Map Remote
Rewrite the URL to point at another address. Use to swap prod traffic to a staging environment.
{
"id": "map-remote-prod-to-staging",
"name": "api.example.com -> staging",
"filter": { "host": "api.example.com" },
"action": {
"type": "MapRemote",
"url": "https://api-staging.example.com",
"preserve_host": false
},
"enabled": true
} Redirect
Return a 3xx redirect.
{
"id": "redirect-legacy",
"name": "/old -> /new",
"filter": { "path": "/old" },
"action": {
"type": "Redirect",
"location": "https://example.com/new",
"status": 301
},
"enabled": true
} Header modification
Add, update, or delete request/response headers. All header actions support the {{previous}} variable to refer to the prior value.
{
"id": "strip-cookie",
"name": "Strip Set-Cookie on /api/*",
"filter": { "path_starts_with": "/api/" },
"action": { "type": "DeleteResponseHeader", "name": "set-cookie" },
"enabled": true
} {
"id": "add-debug",
"name": "Add X-Debug header",
"filter": { "method": "POST" },
"action": {
"type": "AddRequestHeader",
"name": "x-debug",
"value": "relay-core"
},
"enabled": true
} Body modification
Full replace, regex replace, and JSONPath set/delete.
{
"id": "jsonpath-set",
"name": "Force user.role = admin",
"filter": { "host": "api.example.com" },
"action": {
"type": "TransformRequestBody",
"transform": {
"type": "JsonPathSet",
"path": "$.user.role",
"value": "\"admin\""
}
},
"enabled": true
} {
"id": "regex-replace",
"name": "Replace token in body",
"filter": { "path": "/login" },
"action": {
"type": "TransformResponseBody",
"transform": {
"type": "RegexReplace",
"pattern": "secret=([^&]+)",
"replacement": "secret=REDACTED"
}
},
"enabled": true
} Intercept breakpoints
Pause live traffic for human decision. Rules create the breakpoint; resume_flow releases or drops it.
# Create a request-phase breakpoint
curl -X POST http://127.0.0.1:8082/api/v1/intercepts \
-H 'Content-Type: application/json' \
-d '{
"url_pattern": "api.example.com",
"phase": "request"
}' Hit breakpoints show up in the TUI's Intercepts panel, and can be listed via GET /api/v1/intercepts. When resuming, you can attach modifications:
curl -X POST http://127.0.0.1:8082/api/v1/intercepts/<key>/resume \
-H 'Content-Type: application/json' \
-d '{
"action": "continue",
"request_headers": { "x-test": "value" }
}' Modifiable fields: method, url, request_headers, request_body, status_code, response_headers, response_body, message_content (WebSocket).
Flow replay
Resend a captured request/response, with optional modifications.
curl -X POST http://127.0.0.1:8082/api/v1/flows/fld_01HX.../replay \
-H 'Content-Type: application/json' \
-d '{
"modifications": {
"headers": { "x-test": "value" },
"body": "raw body content"
}
}'
# Skip TLS verification (debug only!)
curl -X POST 'http://127.0.0.1:8082/api/v1/flows/fld_01HX.../replay?accept_invalid_certs=true' WebSocket message rewriting
WebSocket traffic has two dedicated actions:
{
"id": "ws-mock",
"name": "Mock chat messages",
"filter": { "host": "chat.example.com" },
"action": {
"type": "MockWebSocketMessage",
"direction": "Incoming",
"message": "{\"type\":\"welcome\",\"user\":\"bot\"}"
},
"enabled": true
} Or unconditionally drop matching messages:
{
"id": "ws-drop-pings",
"name": "Drop ping frames",
"action": { "type": "DropWebSocketMessage" },
"enabled": true
} L3/L4 actions (forward-looking)
The following action types are declared in the rule schema but not all are enabled in every build. See Rule API for current status:
RedirectIp— redirect to a different IPSetTtl— set the IP TTLForwardPort— forward to a different port