github unkn0wn-root/resterm v0.50.0

2 hours ago

v0.50.0

Variables are now expanded before a request is built, and anything left unresolved stops the send instead of going out as literal text. Mock servers can serve a named subset of request files.

Requests fail closed on undefined variables

Until now a {{some_var}} that nothing resolved was substituted as its own literal text and sent that way, so the request went out with {{token}} in a header or {{host}} in the URL. Expansion is now checked before anything is sent. A request that cannot be fully expanded stops with the name of the missing variable and the file and line it came from, so the answer is in the error instead of in the response.

### Users
# @name users
GET https://api.example.com/users
X-Trace: {{traceID}}

expand header X-Trace (api.http:10): undefined variable: traceID

This covers URLs, query parameters, headers, auth values, expanded bodies, gRPC targets and messages and WebSocket steps. Couple of other examples:

expand url: undefined variable: host
expand bearer auth token (auth.http:3): undefined variable: auth.globalToken
expand apikey auth value: undefined variable: apiKey

Explain previews still render. They keep the {{...}} text as written, list the missing names in the trace, and mark the auth stage auth preview skipped. A preview never sends, so a request that fails to expand can still be inspected.

Structural problems keep failing everywhere, previews included, and they win over an undefined variable when a request has both. That means variable cycles, nested expansion depth and expression errors.

What to check after upgrading. Any request that worked by accident with a missing variable now fails. Define the value, pick the right environment with Ctrl+E, or drop the placeholder. Worth a look at @auth command blocks that reuse a slot by cache_key alone: on a cold start there is nothing seeded yet, so keep argv on them.

Serve mocks from named files

resterm mock could serve one file or a whole directory. You can now name the files, on the CLI and in the TUI.

resterm mock --source users.http,payments.http ./workspace
resterm mock --source users.http --source payments.http
resterm mock verify --source users.http,payments.http

Inside the TUI, :mock start and :mock restart took only an address before. They now take the same flags as the CLI, including -- addr, the short aliases, and the --flag=value form:

:mock start 127.0.0.1:9000 --source users.http
:mock restart --source users.http,payments.http
:mock restart --all
:mock status

Command popup

The : suggestion popup could not show both a command and its description. With the mock flags written in the label, the description column was one character wide. The columns now split the row with a minimum width each, cut text ends in an
ellipsis, and the full text appears once you type an argument after a subcommand.

Don't miss a new resterm release

NewReleases is sending notifications on new releases.