>_ RESTERM
v1.10.2
cli.md

docs CLI

resterm mock

Serve, reset, clear and verify mock servers from the command line.

Serve mock response blocks from one request file or a workspace:

shell
resterm mock ./api.http
resterm mock --recursive --addr 127.0.0.1:9090 ./requests
Flag Short Description
--addr <host:port> -a Listen address (default 127.0.0.1:8080).
--cors <policy> auto, off, *, or a comma-separated origin allowlist.
--tls-cert <file> Serve HTTPS using this PEM certificate (requires --tls-key).
--tls-key <file> PEM private key for --tls-cert.
--recursive -r Scan nested workspace directories.
--watch -w Reload source files and referenced body fixtures (enabled by default).
--quiet -q Hide per-request access summaries.
--sequence-key-limit <n> Maximum distinct keys retained by each keyed sequence (default 10000).
--journal-entries <n> Maximum requests retained for verification (default 2000).
--journal-bytes <size> Total retained-data budget for the verification journal (default 16MiB).
--journal-body-limit <size> Body bytes retained per journaled request (default 64KiB).

--cors=auto allows browser clients on loopback and disables CORS for non-loopback binds. Binding to a non-loopback address prints an exposure warning. Reloads are atomic: invalid edits are reported and the last valid route set stays live. Stop the server with Ctrl+C or SIGTERM. In-flight requests get a short grace period to finish.

--tls-cert and --tls-key switch the server to HTTPS. Resterm does not generate certificates. Bring your own pair, for example with mkcert:

shell
mkcert -install
mkcert 127.0.0.1 localhost
resterm mock --tls-cert ./127.0.0.1+1.pem --tls-key ./127.0.0.1+1-key.pem ./requests

mkcert -install adds the local CA to supported system trust stores, which Resterm uses by default. For explicit per-request trust, find the public rootCA.pem in the directory printed by mkcert -CAROOT, copy it next to the request file, and add:

http
# @setting http-root-cas ./rootCA.pem

Relative CA paths resolve from the request file. Do not copy or share rootCA-key.pem.

Mock operations

A running standalone mock server exposes a narrow loopback-only control channel for Resterm's own operational commands. It is not a general mock administration API. The TUI-owned server does not enable it, and it never exposes raw journal entries. The literal /.resterm/ path namespace is reserved for these endpoints: mocks cannot declare routes inside it, and wildcard routes that overlap it are shadowed while the control channel is enabled.

shell
# Reset all sequences, or every sequence named polling.
resterm mock reset
resterm mock reset polling

# Clear the verification journal and request logs.
resterm mock clear

# Check # @expect declarations loaded from a file or workspace.
resterm mock verify payments.http
resterm mock verify --recursive .

The operations connect to http://127.0.0.1:8080 by default. Each accepts --url, --timeout, and --insecure, and verify also accepts --recursive. Flags may go on either side of the optional sequence or source argument, for example:

shell
resterm mock reset polling --url http://127.0.0.1:9090
resterm mock verify payments.http --url https://localhost:9443 --insecure

The URL must contain only the http or https scheme and host. Operational commands intentionally do not support proxy base paths. Source files or directories named reset, clear, or verify should be passed with an explicit path such as ./reset so they are not interpreted as operations.

verify exits 0 when every exact call count passes, 1 for mismatches, an incomplete journal, or a connection failure, and 2 for invalid usage, an invalid source, or a missing @expect declaration. Operational requests are excluded from both request counts and access logs.

See Mock Servers for the response-block syntax, matching rules, selectors, and TUI commands.

Search

↑↓ moveEnter openEsc close

Help

These keys work like the ones in the TUI.

/
Search the docs (also Ctrl K)
j k
Scroll down and up
g g G
Jump to the top or the bottom
[ ]
Previous and next docs page
g d
Docs index
g h
Home page
t
Switch between dark and light
?
Show this help
Esc
Close a dialog