Skip to content

Built-in Values

HTTP requests are parsed and matched with a base template. The base template defines the following variables:

VariableNote
methodThe http request method, e.g., GET, POST, PUT
originThe request origin, including the schema and domain
pathnameThe request path, up to the ?search part
searchThe request search params, as an object largely compatible with URLSearchParams
headersThe request headers, as an object largely compatible with Headers
bodyThe request body, usually as a string.

In the templates, ANY https://.... declares a request with no request method (which matches any), and ANY // can be used to define a request with no origin to match anything. These forms are useful for writing mixin requests.

In the pathname, {{variable}} will have a default regex of /[^/]+/, i.e., one or more non-slash characters, while the hint ... as in {{...variable}} matches /.*/ (anything).

Similarly, in the origin, {{variable}} matches /[^.]+/ (one or more non-dots), and {{...variable}} matches /.*/ (anything).

HTTP responses are parsed and matched with a base template. The base template defines the following variables:

VariableNote
statusThe response status
headersThe response headers, as an object largely compatible with Headers
bodyThe response body, usually as a string.

There are two meta-headers, body and resolve

POST https://example.com/...
[body]: plain
[resolve]: localhost

body overrides the normal guess for how to parse the request or response body. Options are

[body]behavior
plainplain text, supports {{interpolation}}
rawraw text
jsonJSON or scripted templates
formurl-encoded form data, supports {{interpolation}}

The [resolve] meta header specifies the DNS name or IP address to connect to. This overrides DNS only, the host header and SNI will still be based on the origin of the request. This mimics curl’s --resolve option.