Skip to main content
Map local lets you serve files from your machine instead of fetching them from the upstream server. Use it to test API responses, mock endpoints, or override assets without changing your backend. Map local is implemented through the scripting system using ctx.respondWith({file}).

Quick add via TUI

Press S to open the scripts manager, then m to add a Map Local rule. Enter a URL pattern and a local file path — httpmon generates a script that serves the file for matching requests.
KeyAction
SOpen scripts manager
mAdd a new Map Local rule
TabSwitch between pattern and path fields
EnterSave the rule
EscCancel

Via scripts

Use ctx.respondWith with the file option in an onRequest hook.
// ---
// name: Mock Config Endpoint
// match:
//   - "*://api.example.com/config"
// enabled: true
// ---

function onRequest(ctx) {
  ctx.respondWith({ file: "config.json" });
}
The file path is relative to the script directory (~/.httpmon/scripts/). The content type is auto-detected from the file extension. You can also return inline content:
function onRequest(ctx) {
  ctx.respondWith({
    status: 200,
    body: '{"mocked": true}',
    headers: { "Content-Type": "application/json" }
  });
}
See scripting for the full script API.

How it works

When a request matches a map local script, httpmon returns the local file’s content directly to the client without contacting the upstream server. The ctx.respondWith() call in onRequest halts script execution immediately and sends the synthetic response. Scripts that use ctx.respondWith() are tagged with a Map Local badge in the scripts manager so you can tell them apart from regular scripts.