Modifiers
Request Header
Couper offers three attributes to manipulate the request header fields. The header attributes can be defined unordered within the configuration file but will be executed ordered as follows:
Modifier | Contexts | Description |
---|---|---|
remove_request_headers | Endpoint Block, Proxy Block, Backend Block, Error Handler | List of request header to be removed from the upstream request. |
set_request_headers | Endpoint Block, Proxy Block, Backend Block, Error Handler | Key/value(s) pairs to set request header in the upstream request. |
add_request_headers | Endpoint Block, Proxy Block, Backend Block, Error Handler | Key/value(s) pairs to add request header to the upstream request. |
All *_request_headers
are executed from: endpoint
, proxy
, backend
and error_handler
.
Response Header
Couper offers three attributes to manipulate the response header fields. The header attributes can be defined unordered within the configuration file but will be executed ordered as follows:
Modifier | Contexts | Description |
---|---|---|
remove_response_headers | Server Block, Files Block, SPA Block, API Block, Endpoint Block, Proxy Block, Backend Block, Error Handler | List of response header to be removed from the client response. |
set_response_headers | Server Block, Files Block, SPA Block, API Block, Endpoint Block, Proxy Block, Backend Block, Error Handler | Key/value(s) pairs to set response header in the client response. |
add_response_headers | Server Block, Files Block, SPA Block, API Block, Endpoint Block, Proxy Block, Backend Block, Error Handler | Key/value(s) pairs to add response header to the client response. |
All *_response_headers
are executed from: server
, files
, spa
, api
, endpoint
, proxy
, backend
and error_handler
.
Set Response Status
The set_response_status
attribute allows to modify the HTTP status code to the
given value.
Modifier | Contexts | Description |
---|---|---|
set_response_status | Endpoint Block, Backend Block, Error Handler | HTTP status code to be set to the client response. |
If the HTTP status code ist set to 204
, the response body and the HTTP header
field Content-Length
is removed from the client response, and a warning is logged.
Parameters
Query Parameter
Couper offers three attributes to manipulate the query parameter. The query attributes can be defined unordered within the configuration file but will be executed ordered as follows:
Modifier | Contexts | Description |
---|---|---|
remove_query_params | Endpoint Block, Proxy Block, Backend Block, Error Handler | List of query parameters to be removed from the upstream request URL. |
set_query_params | Endpoint Block, Proxy Block, Backend Block, Error Handler | Key/value(s) pairs to set query parameters in the upstream request URL. |
add_query_params | Endpoint Block, Proxy Block, Backend Block, Error Handler | Key/value(s) pairs to add query parameters to the upstream request URL. |
All *_query_params
are executed from: endpoint
, proxy
, backend
and error_handler
.
server "my_project" {
api {
endpoint "/" {
proxy {
backend = "example"
}
}
}
}
definitions {
backend "example" {
origin = "http://example.com"
remove_query_params = ["a", "b"]
set_query_params = {
string = "string"
multi = ["foo", "bar"]
"${request.headers.example}" = "yes"
}
add_query_params = {
noop = request.headers.noop
null = null
empty = ""
}
}
}
Form Parameter
Couper offers three attributes to manipulate the form parameter. The form attributes can be defined unordered within the configuration file but will be executed ordered as follows:
Modifier | Contexts | Description |
---|---|---|
remove_form_params | Endpoint Block, Proxy Block, Backend Block, Error Handler | List of form parameters to be removed from the upstream request body. |
set_form_params | Endpoint Block, Proxy Block, Backend Block, Error Handler | Key/value(s) pairs to set form parameters in the upstream request body. |
add_form_params | Endpoint Block, Proxy Block, Backend Block, Error Handler | Key/value(s) pairs to add form parameters to the upstream request body. |
All *_form_params
are executed from: endpoint
, proxy
, backend
and error_handler
.
The *_form_params
apply only to requests with the POST
method and
the Content-Type: application/x-www-form-urlencoded
HTTP header field.
server "my_project" {
api {
endpoint "/" {
proxy {
backend = "example"
}
}
}
}
definitions {
backend "example" {
origin = "http://example.com"
remove_form_params = ["a", "b"]
set_form_params = {
string = "string"
multi = ["foo", "bar"]
"${request.headers.example}" = "yes"
}
add_form_params = {
noop = request.headers.noop
null = null
empty = ""
}
}
}