v1.3.1
Shorter request URLs
You can now set a base URL once and write paths relative to it, or omit http:// when the target includes a host and port.
The base-url setting
base-url is a new setting that lets a request line contain only a path.
# @setting base-url https://api.example.com/v1/
### List users
GET users?page=2
### Health check
GET /healthThese requests are sent to https://api.example.com/v1/users?page=2 and https://api.example.com/health.
You can set base-url at the environment, file, or request level. A request-level setting takes precedence over a file-level setting, which takes precedence over the environment file.
{
"dev": { "settings.base-url": "https://api.dev.example.com/v1/" },
"prod": { "settings.base-url": "https://api.example.com/v1/" }
}Relative targets follow the standard URL resolution rules:
usersis appended to the base path/usersreplaces the base path../healthmoves up one path segment?page=2keeps the current path and replaces the query//uploads.example.com/xkeeps the scheme but replaces the host
The trailing slash matters. Combining https://api.example.com/v1/ with users produces /v1/users, while combining https://api.example.com/v1 with users produces /users. An absolute request URL ignores base-url. The setting works with REST, GraphQL, SSE, and WebSocket requests; gRPC targets are unchanged.
Both the base URL and request target can contain template expressions. The base URL is resolved only when the request target needs it, so an unresolved base does not affect requests that already contain an absolute URL.
# @setting base-url {{services.api.base}}
GET orders/42Host and port targets
A target containing a host and port is now treated as an HTTP URL automatically. For example, GET localhost:8080/users previously failed with unsupported protocol scheme "localhost"; it now uses http://.
### Local development server
GET localhost:8080/users
### IP address
GET 127.0.0.1:8080/users
### IPv6 address
GET [::1]:8080/usersWith @websocket, the inferred scheme is ws://, so this connects to ws://localhost:8080/socket:
# @websocket
GET localhost:8080/socketThe explicit port makes the target unambiguous. A name without a port is still treated as a relative path, so GET example.com/users resolves against base-url. Include the scheme when you intend it to be an absolute host.
Targets containing embedded credentials are rejected because those credentials could otherwise be sent as an Authorization header:
GET user@example.com:8080/path
request url must not carry credentials, use @auth basic instead
Other fixes
- Setting names are now case-insensitive across scopes, so Base-Url and base-url are treated as the same setting when values are merged
- Environment entries beginning with
settings.are now parsed correctly when surrounded by whitespace. - A
ws://URL without@websocketnow reports that the directive is missing instead of saying the scheme must be HTTP or HTTPS.