Servers
The same commands prove HTTP servers. --http says the command starts a server; it takes its
port from PORT or {port} in the command (--port for one that always listens on the same
port):
sh
rust-anything app record . --http -- node server.js
rust-anything app replay .
rust-anything app front-door . # axum: every route proxied
rust-anything app wire . api --route 'GET /users/{id}' --route '*'
rust-anything app lift .
- Requests come from
curllines in the app's docs (curl -X POST -d ... http://localhost:8080/x),--inputs({"name", "method", "path", "headers", "body"}) and traps: path segments and query values swapped for the same traps as CLI arguments, bodies for text and JSON traps, and an unknown route. Each run starts the server fresh and sends the requests in name order, so state between requests is kept. - A server that keeps state in files gets a fresh copy for every start:
--fresh db.json(a file or folder, repeatable) is snapshotted intohttp/files/and copied into a new working directory each time the original, the front door or a build starts;--arg db.jsonis an argument every start gets after its command, so the Rust binary is started as the original is.--pace 50waits 50 ms after each response, for work a server does after answering (a file watcher reloading what it just wrote). - Cases are
rust/app-cases/http/<case>.toml(the request, the status and the headers that matter) and<case>.body(the response body, with[..]where two runs differed). Date, server and other per-response headers are left out; delete any header line you do not care about. - The front door is an axum server that starts the original on a port of its own and proxies
every route no unit answers.
wire --routetakes axum routes:METHOD /path/{param},/pathfor any method,*for everything else; the glue gets the route, its parameters and the request.liftremoves the proxy; HTTP cases then run in CI withapp replay.
A real one
json-server needed --fresh, --arg and --pace: it rewrites its database on every write, and its file watcher can undo a write that follows quickly.