Couper Documentation

edge

Request

The request block creates and executes a request to a backend service.

📝 Multiple proxy and request blocks are executed in parallel.

Block nameContextLabel
requestEndpoint Block⚠ A Proxy Block or Request Block w/o a label has an implicit label "default". Only one Proxy Block or Request Block w/ label "default" per Endpoint Block is allowed.

Attributes

NameTypeDefaultDescription
backend
string
-

References a backend in definitions for the request. Mutually exclusive with backend block.

body
string
-

Plain text request body, implicitly sets Content-Type: text/plain header field.

expected_status
tuple (int)
[]

If defined, the response status code will be verified against this list of codes. If the status code is not included in this list an unexpected_status error will be thrown which can be handled with an error_handler.

form_body
string
-

Form request body, implicitly sets Content-Type: application/x-www-form-urlencoded header field.

headers
object
-

Same as set_request_headers in Modifiers - Request Header.

json_body
string
-

JSON request body, implicitly sets Content-Type: application/json header field.

method
string
"GET"

The request method.

query_params
object
-

Key/value pairs to set query parameters for this request.

url
string
-

URL of the resource to request. May be relative to an origin specified in a referenced or nested backend block.

If the url attribute is specified and its value is an absolute URL, the protocol and host parts must be the same as in the value of the {origin} attribute of the used backend.

Nested Blocks

NameDescription
backend

Configures a backend for the request (zero or one). Mutually exclusive with backend attribute.

Examples

request {
  url = "https://httpbin.org/anything"
  body = "foo"
}