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.

Via scripts

The scripting engine is the preferred way to serve local files. Use ctx.respondWith in an onRequest hook.
// ---
// name: Mock Config Endpoint
// match:
//   - "*://api.example.com/config"
// enabled: true
// ---

function onRequest(ctx) {
  ctx.respondWith({ file: "path/to/config.json" });
}
See scripting for the full script API.

Via CLI

You can also define map local rules in a JSON file and pass it at startup.
httpmon --maplocal rules.json

Rules JSON format

The file contains an array of rule objects.
[
  {
    "pattern": "api.example.com/config",
    "local_path": "/path/to/config.json",
    "status_code": 200
  },
  {
    "pattern": "*.example.com/styles/*",
    "local_path": "/path/to/override.css"
  }
]
FieldRequiredDescription
patternYesURL pattern to match. Supports * wildcards.
local_pathYesAbsolute path to the local file to serve.
status_codeNoHTTP status code to return. Defaults to 200.

TUI manager

Press M to open the map local manager.
KeyAction
nAdd a new rule (pattern + local path, Tab to switch fields)
dDelete a rule (with confirmation)
EscClose the manager
Changes auto-save back to the rules file.

How it works

When a request matches a map local rule, httpmon returns the local file’s content directly to the client without contacting the upstream server. The content type is auto-detected from the file extension. Flows served from local files show a [L] indicator in the flow list so you can tell them apart from upstream responses.
httpmon map local rules