~/.httpmon/scripts/. Each script is a .js file with YAML frontmatter in comments followed by JavaScript hook functions.
Script format
A script has two parts: a YAML frontmatter block (wrapped in// --- comment delimiters) and one or both hook functions.
Frontmatter fields
| Field | Required | Description |
|---|---|---|
name | Yes | Display name shown in the script manager |
match | Yes | URL patterns to match. Supports * wildcards. |
enabled | No | true or false. Defaults to true if omitted. |
Hooks
onRequest(ctx) runs before the request is sent to the server.
| Field | Type | Description |
|---|---|---|
ctx.method | string | HTTP method (read/write) |
ctx.url | string | Full URL (read/write) |
ctx.headers | object | Request headers (read/write) |
ctx.body | string | Request body (read) |
ctx.blocked | bool | Set to true to block the request |
ctx.respondWith() | function | Return a synthetic response without hitting the server |
ctx.breakpoint() | function | Pause the request and open an interactive editor |
onResponse(ctx) runs before the response reaches the client.
| Field | Type | Description |
|---|---|---|
ctx.status | int | Status code (read/write) |
ctx.headers | object | Response headers (read/write) |
ctx.body | string | Response body (read) |
Script manager
Press S in the TUI to open the script manager. From there you can toggle, create, and delete scripts.| Key | Action |
|---|---|
| Space | Toggle a script on or off |
| n | Create a new script from a template |
| d | Delete a script (with confirmation) |

Examples
All examples below use httpbin.org so you can test them immediately.Modify request headers
Modify request headers
Add custom headers to outgoing requests. The httpbin
/headers endpoint echoes back all received headers, so you can verify the script works.Modify response headers
Modify response headers
Override the status code or headers on a response before it reaches the client.
Block requests
Block requests
Block all requests to slow endpoints. Blocked requests never leave the proxy.
Mock a response
Mock a response
Return a synthetic JSON response without hitting the server. Use
ctx.respondWith() to define the status, body, and headers.Serve a local file
Serve a local file
Serve a file from disk instead of forwarding the request. The
file path is relative to the script directory (~/.httpmon/scripts/).Set a breakpoint
Set a breakpoint
Pause the request flow and open an interactive editor. You can inspect and modify the request before it is sent to the server.
Add an auth header
Add an auth header
Inject a bearer token into requests. The httpbin
/bearer endpoint validates the Authorization header and returns 200 on success or 401 without it.Redirect requests
Redirect requests
Rewrite the URL to redirect a request to a different endpoint. The client sees the response from the new URL.
URL matching
Thematch field accepts an array of glob patterns. Use * as a wildcard for any sequence of characters.
| Pattern | Matches |
|---|---|
*://httpbin.org/* | Any scheme, any path on httpbin.org |
*://httpbin.org/get | Only the /get endpoint |
*://httpbin.org/delay/* | Any delay duration |
*://*.example.com/* | Any subdomain of example.com |
Error handling
If a script throws an error, httpmon catches it and continues processing the request normally. The error is tracked and displayed in the script manager next to the script name, so you can spot and fix issues without disrupting traffic.See the Script API reference for the full list of context fields and methods.

