Repository: avenga/couper (go)

Issue:
Rename short `request` and `response` related variable names 
As we had received some feedback from users which have no related background to varnish, which inspired us to use `bereq`, `beresp` and `req` as names, we would like to refine this configuration part to be more expressive instead of the requirement looking up variable name specifications in the first place.

Following renames:
`req` -> `request`
`ctx` -> `context`
`bereq` -> removed
`beresp` -> removed
`bereqs` -> `backend_requests`
`beresps` -> `backend_responses`

`bereq` and `beresp` were shortcuts for `beresps.default.var`. There is no drop in replacement at the moment and we will discuss a possible `default` label shortcut later on. Accessing the `default` one: `backend_responses.default.*`.

Pull request:
Change variable names: req, ctx, bereq, beresp
request, context, backend_requests, backend_responses

Closes #180 

Patch:
diff --git a/DOCKER.md b/DOCKER.md
index 11ec967e..b639efb3 100644
--- a/DOCKER.md
+++ b/DOCKER.md
@@ -25,7 +25,7 @@ docker run --rm -p 8080:8080 -v `pwd`:/htdocs avenga/couper
 | COUPER_XFH    | `false`   | Global configurations which uses the `Forwarded-Host` header instead of the request host.   |
 | COUPER_HEALTH_PATH    | `/healthz`   | Path for health-check requests for all servers and ports.   |
 | COUPER_NO_PROXY_FROM_ENV | `false` | Disables the connect hop to configured [proxy via environment](https://godoc.org/golang.org/x/net/http/httpproxy). |
-| COUPER_REQUEST_ID_FORMAT    | `common`   | If set to `uuid4` a rfc4122 uuid is used for `req.id` and related log fields.   |
+| COUPER_REQUEST_ID_FORMAT    | `common`   | If set to `uuid4` a rfc4122 uuid is used for `request.id` and related log fields.   |
 | COUPER_SECURE_COOKIES | `""` | If set to `"strip"`, the `Secure` flag is removed from all `Set-Cookie` HTTP header fields. |
 | COUPER_ACCESS_LOG_PARENT_FIELD | `""`  | An option for `json` log format to add all log fields as child properties. |
 | COUPER_ACCESS_LOG_TYPE_VALUE | `couper_access`  | Value for the log field `type`. |
diff --git a/config/runtime/server.go b/config/runtime/server.go
index 0d8c149c..44810deb 100644
--- a/config/runtime/server.go
+++ b/config/runtime/server.go
@@ -329,7 +329,7 @@ func NewServerConfiguration(
 				}}
 			}
 
-			// TODO: determine req/beresp.body access in this context (all including backend) or for now:
+			// TODO: determine request/backend_responses.*.body access in this context (all including backend) or for now:
 			bufferOpts := eval.MustBuffer(endpointConf.Remain)
 			if len(proxies)+len(requests) > 1 { // also buffer with more possible results
 				bufferOpts |= eval.BufferResponse
diff --git a/docs/README.md b/docs/README.md
index 70425749..e2945b3f 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -11,11 +11,9 @@
     * [Nesting of configuration blocks and attributes](#nesting-of-configuration-blocks-and-attributes)
   * [Variables](#variables)
     * [`env`](#env-variable)
-    * [`req`](#req-client-request-variable)
-    * [`bereq`](#bereq-modified-backend-request-variable)
-    * [`bereqs`](#bereqs-modified-backend-requests-variable)
-    * [`beresp`](#beresp-original-backend-response-variable)
-    * [`beresps`](#beresps-original-backend-responses-variable)
+    * [`request`](#request-client-request-variable)
+    * [`backend_requests`](#backend_requests-modified-backend-requests-variables)
+    * [`backend_responses`](#backend_responses-non-modified-backend-responses-variables)
     * [Variable example](#variable-example)
   * [Expressions](#expressions)
   * [Functions](#functions)
@@ -101,27 +99,35 @@ For orientation compare the following example and the information below:
 
 ```hcl
 server "my_project" {
-  files { ... }
+  files { 
+    # ...
+  }
 
-  spa { ... }
+  spa {
+    # ...
+  }
 
   api {
     access_control = ["foo"]
     endpoint "/bar" {
       proxy {
-        backend { ... }
+        backend { }
       }
       request "sub-request" {
-        backend { ... }
+        backend { }
       }
-      response { ... }
+      response { }
     }
   }
 }
 
-definitions { ... }
+definitions {
+  # ...
+}
 
-settings { ... }
+settings {
+  # ...
+}
 ```
 
 * `server` main configuration block(s)
@@ -180,11 +186,9 @@ which is currently related to `env` and **function** usage. The second evaluatio
 will happen during the request/response handling.
 
 * `env` are the environment variables
-* `req` is the client request
-* `bereq` is the modified backend request
-* `bereqs` contains all modified backend requests
-* `beresp` is the original backend response from proxy or request block with label "default" (no label equals to label "default")
-* `beresps` contains all original backend responses
+* `request` is the client request
+* `backend_requests` contains all modified backend requests
+* `backend_responses` contains all original backend responses
 
 Most fields are self-explanatory (compare tables below).
 
@@ -193,7 +197,7 @@ Most fields are self-explanatory (compare tables below).
 Environment variables can be accessed everywhere within the configuration file
 since these references get evaluated at start.
 
-#### `req` (client request) variable
+#### `request` (client request) variable
 
 | Variable                  | Description |
 |:--------------------------|:------------|
@@ -207,9 +211,14 @@ since these references get evaluated at start.
 | `path_params.<name>`      | Value from a named path parameter defined within an endpoint path label |
 | `form_body.<name>`        | Parameter in a `application/x-www-form-urlencoded` body |
 | `json_body.<name>`        | Access json decoded object properties. Media type must be `application/json`. |
-| `ctx.<name>.<property_name>` | Request context containing claims from JWT used for [Access Control](#access-control) or information from a SAML assertion, `<name>` being the [JWT Block's](#jwt-block) or [SAML Block's](#saml-block) label and `property_name` being the claim's or assertion information's name |
+| `context.<name>.<property_name>` | Request context containing claims from JWT used for [Access Control](#access-control) or information from a SAML assertion, `<name>` being the [JWT Block's](#jwt-block) or [SAML Block's](#saml-block) label and `property_name` being the claim's or assertion information's name |
+
+#### `backend_requests` (modified backend requests) variables
 
-#### `bereq` (modified backend request) variable
+`backend_requests.<label>` is a list of all backend requests, and their variables.
+To access a specific request use the related label. [Request](#request-block) and
+[Proxy](#proxy-block) blocks without a label will be available as `default`.
+To access the HTTP method of the `default` request use `backend_requests.default.method` .
 
 | Variable                  | Description |
 |:--------------------------|:------------|
@@ -220,15 +229,15 @@ since these references get evaluated at start.
 | `cookies.<name>`          | Value from `Cookie` request header for requested key (&#9888; last wins!) |
 | `query.<name>`            | Query parameter values (&#9888; last wins!) |
 | `form_body.<name>`        | Parameter in a `application/x-www-form-urlencoded` body |
-| `ctx.<name>.<property_name>` | Request context containing claims from JWT used for [Access Control](#access-control) or information from a SAML assertion, `<name>` being the [JWT Block's](#jwt-block) or [SAML Block's](#saml-block) label and `property_name` being the claim's or assertion information's name |
+| `context.<name>.<property_name>` | Request context containing claims from JWT used for [Access Control](#access-control) or information from a SAML assertion, `<name>` being the [JWT Block's](#jwt-block) or [SAML Block's](#saml-block) label and `property_name` being the claim's or assertion information's name |
 | `url`                     | Backend origin URL |
 
-#### `bereqs` (modified backend requests) variable
-
-`bereqs` ist a list of all `bereq` variables with the access via label.
-To access the HTTP method of the `default` request use `beresps.default.method`
+#### `backend_responses` (non modified backend responses) variables
 
-#### `beresp` (original backend response) variable
+`backend_responses.<label>` is a list of all backend responses, and their variables. Same behaviour as for `backend_requests`.
+Use the related label to access a specific response.
+[Request](#request-block) and [Proxy](#proxy-block) blocks without a label will be available as `default`.
+To access the HTTP status code of the `default` response use `backend_responses.default.status` .
 
 | Variable           | Description |
 |:-------------------|:------------|
@@ -237,11 +246,6 @@ To access the HTTP method of the `default` request use `beresps.default.method`
 | `cookies.<name>`   | Value from `Set-Cookie` response header for requested key (&#9888; last wins!) |
 | `json_body.<name>` | Access json decoded object properties. Media type must be `application/json`. |
 
-#### `beresps` (original backend responses) variable
-
-`beresps` ist a list of all `beresp` variables with the access via label.
-To access the HTTP status code of the `default` response use `beresps.default.status`
-
 ##### Variable Example
 
 An example to send an additional header with client request header to a configured
@@ -255,8 +259,8 @@ server "variables-srv" {
         backend "my_backend_definition" {
           set_request_headers = {
             x-env-user = env.USER
-            user-agent = "myproxyClient/${req.headers.app-version}"
-            x-uuid = req.id
+            user-agent = "myproxyClient/${request.headers.app-version}"
+            x-uuid = request.id
           }
         }
       }
@@ -309,24 +313,24 @@ my_attribute = base64_decode("aGVsbG8gd29ybGQK")
 iat = unixtime()
 
 my_json = json_encode({
-  value-a: beresp.json_body.origin
+  value-a: backend_responses.default.json_body.origin
   value-b: ["item1", "item2"]
 })
 
-merge({"k1": 1}, null, {"k2": 2})          // -> {"k1": 1, "k2": 2}        merge object attributes
-merge({"k": [1]}, {"k": [2]})              // -> {"k": [1, 2]}             merge tuple values
-merge({"k": {"k1": 1]}}, {"k": {"k2": 2}}) // -> {"k": {"k1": 1, "k2": 2}} merge object attributes
-merge({"k": [1]}, {"k": null}, {"k": [2]}) // -> {"k": [2]}                remove value and set new value
-merge({"k": [1]}, {"k": 2})                // -> {"k": 2}                  set new value
-merge([1], null, [2, "3"], [true, false])  // -> [1, 2, "3", true, false]  merge tuple values
+x = merge({"k1": 1}, null, {"k2": 2})          // -> {"k1": 1, "k2": 2}        merge object attributes
+x = merge({"k": [1]}, {"k": [2]})              // -> {"k": [1, 2]}             merge tuple values
+x = merge({"k": {"k1": 1}}, {"k": {"k2": 2}})  // -> {"k": {"k1": 1, "k2": 2}} merge object attributes
+x = merge({"k": [1]}, {"k": null}, {"k": [2]}) // -> {"k": [2]}                remove value and set new value
+x = merge({"k": [1]}, {"k": 2})                // -> {"k": 2}                  set new value
+x = merge([1], null, [2, "3"], [true, false])  // -> [1, 2, "3", true, false]  merge tuple values
 
-merge({"k1": 1}, 2)                        // -> error: cannot mix object with primitive value
-merge({"k1": 1}, [2])                      // -> error: cannot mix object with tuple
-merge([1], 2)                              // -> error: cannot mix tuple with primitive value
+x = merge({"k1": 1}, 2)                        // -> error: cannot mix object with primitive value
+x = merge({"k1": 1}, [2])                      // -> error: cannot mix object with tuple
+x = merge([1], 2)                              // -> error: cannot mix tuple with primitive value
 
 token = jwt_sign("MyJwt", {"sub": "abc12345"})
 
-saml_sso_url("MySaml")
+url = saml_sso_url("MySaml")
 
 definitions {
   jwt_signing_profile "MyJwt" {
@@ -437,7 +441,7 @@ produce an explicit or implicit client response.
 | [Request Block(s)](#request-block) |  |
 | [Response Block](#response-block)  |  |
 | **Attributes**                     | **Description** |
-| `request_body_limit`               | <ul><li>Optional.</li><li>Configures the maximum buffer size while accessing `req.form_body` or `req.json_body` content.</li><li>Valid units are: `KiB, MiB, GiB`.</li><li>Default limit is `64MiB`.</li></ul> |
+| `request_body_limit`               | <ul><li>Optional.</li><li>Configures the maximum buffer size while accessing `request.form_body` or `request.json_body` content.</li><li>Valid units are: `KiB, MiB, GiB`.</li><li>Default limit is `64MiB`.</li></ul> |
 | `path`                             | <ul><li>Optional.</li><li>Changeable part of the upstream URL.</li><li>Changes the path suffix of the outgoing request.</li></ul> |
 | `access_control`                   | <ul><li>Optional.</li><li>Sets predefined [Access Control](#access-control) for current `Endpoint Block` context.</li><li>*Example:* `access_control = ["foo"]`</li></ul> |
 | [Modifier](#modifier)              | <ul><li>Optional.</li><li>All [Modifier](#modifier).</li></ul> |
@@ -694,11 +698,11 @@ definitions {
     set_query_params = {
       string = "string"
       multi = ["foo", "bar"]
-      "${req.headers.example}" = "yes"
+      "${request.headers.example}" = "yes"
     }
 
     add_query_params = {
-      noop = req.headers.noop
+      noop = request.headers.noop
       null = null
       empty = ""
     }
@@ -709,13 +713,13 @@ definitions {
 ### Path Parameter
 
 An endpoint label could be defined as `endpoint "/app/{section}/{project}/view" { ... }`
-to access the named path parameter `section` and `project` via `req.path_param.*`.
+to access the named path parameter `section` and `project` via `request.path_params.*`.
 The values would map as following for the request path: `/app/nature/plant-a-tree/view`:
 
 | Variable                  | Value          |
 |:--------------------------|:---------------|
-| `req.path_params.section` | `nature`       |
-| `req.path_params.project` | `plant-a-tree` |
+| `request.path_params.section` | `nature`       |
+| `request.path_params.project` | `plant-a-tree` |
 
 ### Access Control
 
@@ -820,11 +824,11 @@ mandatory *label*.
 | `sp_entity_id`             | <ul><li>&#9888; Mandatory.</li><li>The Service Provider's entity ID.</li></ul> |
 | `array_attributes`         | <ul><li>Optional.</li><li>A list of assertion attributes that may have several values.</li></ul> |
 
-Some information from the assertion consumed at the ACS endpoint is provided in the context at `req.ctx.<label>`:
+Some information from the assertion consumed at the ACS endpoint is provided in the context at `request.context.<label>`:
 
-* the `NameID` of the assertion's `Subject` (`req.ctx.<label>.sub`)
-* the session expiry date `SessionNotOnOrAfter` (as UNIX timestamp: `req.ctx.<label>.exp`)
-* the attributes (`req.ctx.<label>.attributes.<name>`)
+* the `NameID` of the assertion's `Subject` (`request.context.<label>.sub`)
+* the session expiry date `SessionNotOnOrAfter` (as UNIX timestamp: `request.context.<label>.exp`)
+* the attributes (`request.context.<label>.attributes.<name>`)
 
 ### Settings Block
 
@@ -841,7 +845,7 @@ gateway instance.
 | `default_port`      | Port which will be used if not explicitly specified per host within the [`hosts`](#server-block) list | `8080` |
 | `log_format`        | Switch for tab/field based colored view or json log lines | `common` |
 | `xfh`               | Option to use the `X-Forwarded-Host` header as the request host | `false` |
-| `request_id_format` | If set to `uuid4` a rfc4122 uuid is used for `req.id` and related log fields | `common` |
+| `request_id_format` | If set to `uuid4` a rfc4122 uuid is used for `request.id` and related log fields | `common` |
 | `secure_cookies`    | If set to `"strip"`, the `Secure` flag is removed from all `Set-Cookie` HTTP header fields. | `""` |
 
 ### Health-Check
@@ -905,7 +909,7 @@ api "my_api" {
         # outgoing request: http://accountservice:8080/user/brenda/info
         proxy {
           backend {
-            path = "/user/${req.param.id}/info"
+            path = "/user/${request.param.id}/info"
             origin = "http://accountservice:8080"
           }
         }
@@ -958,10 +962,10 @@ server "ac-example" {
 }
 
 definitions {
-  basic_auth "ac1" { ... }
-  jwt "ac2" { ... }
-  jwt "ac3" { ... }
-  jwt "ac4" { ... }
+  basic_auth "ac1" { }
+  jwt "ac2" { }
+  jwt "ac3" { }
+  jwt "ac4" { }
 }
 ```
 
diff --git a/eval/buffer.go b/eval/buffer.go
index ca64bc9b..9c5beb7b 100644
--- a/eval/buffer.go
+++ b/eval/buffer.go
@@ -45,7 +45,7 @@ func MustBuffer(body hcl.Body) BufferOption {
 			}
 
 			rootName := traversal.RootName()
-			if rootName != ClientRequest && rootName != BackendResponse {
+			if rootName != ClientRequest && rootName != BackendResponses {
 				continue
 			}
 
@@ -60,7 +60,7 @@ func MustBuffer(body hcl.Body) BufferOption {
 				switch rootName {
 				case ClientRequest:
 					result |= BufferRequest
-				case BackendResponse:
+				case BackendResponses:
 					result |= BufferResponse
 				}
 			}
diff --git a/eval/context.go b/eval/context.go
index fe35f002..0f074034 100644
--- a/eval/context.go
+++ b/eval/context.go
@@ -158,12 +158,6 @@ func (c *Context) WithBeresps(beresps ...*http.Response) *Context {
 		}.Merge(newVariable(ctx.inner, beresp.Cookies(), beresp.Header)))
 	}
 
-	if val, ok := bereqs[BackendDefault]; ok {
-		ctx.eval.Variables[BackendRequest] = val
-	}
-	if val, ok := resps[BackendDefault]; ok {
-		ctx.eval.Variables[BackendResponse] = val
-	}
 	ctx.eval.Variables[BackendRequests] = cty.ObjectVal(bereqs)
 	ctx.eval.Variables[BackendResponses] = cty.ObjectVal(resps)
 
diff --git a/eval/variables.go b/eval/variables.go
index f5dc28f4..0acfef55 100644
--- a/eval/variables.go
+++ b/eval/variables.go
@@ -1,13 +1,11 @@
 package eval
 
 const (
-	BackendRequest   = "bereq"
-	BackendResponse  = "beresp"
-	BackendRequests  = "bereqs"
-	BackendResponses = "beresps"
+	BackendRequests  = "backend_requests"
+	BackendResponses = "backend_responses"
 	BackendDefault   = "default"
-	ClientRequest    = "req"
-	CTX              = "ctx"
+	ClientRequest    = "request"
+	CTX              = "context"
 	Cookies          = "cookies"
 	Endpoint         = "endpoint"
 	Environment      = "env"


Test patch:
diff --git a/eval/context_test.go b/eval/context_test.go
index 33c143f3..ae767fe0 100644
--- a/eval/context_test.go
+++ b/eval/context_test.go
@@ -44,41 +44,41 @@ func TestNewHTTPContext(t *testing.T) {
 		want      http.Header
 	}{
 		{"Variables / POST", http.MethodPost, http.Header{"Content-Type": {"application/x-www-form-urlencoded"}}, bytes.NewBufferString(`user=hans`), "", baseCtx, `
-					post = req.form_body.user[0]
-					method = req.method
+					post = request.form_body.user[0]
+					method = request.method
 		`, http.Header{"post": {"hans"}, "method": {http.MethodPost}}},
 		{"Variables / Query", http.MethodGet, http.Header{"User-Agent": {"test/v1"}}, nil, "?name=peter", baseCtx, `
-					query = req.query.name[0]
-					method = req.method
-					ua = req.headers.user-agent
+					query = request.query.name[0]
+					method = request.method
+					ua = request.headers.user-agent
 				`, http.Header{"query": {"peter"}, "method": {http.MethodGet}, "ua": {"test/v1"}}},
 		{"Variables / Headers", http.MethodGet, http.Header{"User-Agent": {"test/v1"}}, nil, "", baseCtx, `
-					ua = req.headers.user-agent
-					method = req.method
+					ua = request.headers.user-agent
+					method = request.method
 				`, http.Header{"ua": {"test/v1"}, "method": {http.MethodGet}}},
 		{"Variables / PATCH /w json body", http.MethodPatch, http.Header{"Content-Type": {"application/json;charset=utf-8"}}, bytes.NewBufferString(`{
 			"obj_slice": [
 				{"no_title": 123},
 				{"title": "success"}
 			]}`), "", baseCtx, `
-			method = req.method
-			title = req.json_body.obj_slice[1].title
+			method = request.method
+			title = request.json_body.obj_slice[1].title
 		`, http.Header{"title": {"success"}, "method": {http.MethodPatch}}},
 		{"Variables / PATCH /w json body /wo CT header", http.MethodPatch, nil, bytes.NewBufferString(`{"slice": [1, 2, 3]}`), "", baseCtx, `
-			method = req.method
-			title = req.json_body.obj_slice
+			method = request.method
+			title = request.json_body.obj_slice
 		`, http.Header{"method": {http.MethodPatch}}},
 		{"Variables / GET /w json body", http.MethodGet, http.Header{"Content-Type": {"application/json"}}, bytes.NewBufferString(`{"slice": [1, 2, 3]}`), "", baseCtx, `
-			method = req.method
-			title = req.json_body.slice
+			method = request.method
+			title = request.json_body.slice
 		`, http.Header{"title": {"1", "2", "3"}, "method": {http.MethodGet}}},
 		{"Variables / GET /w json body & missing attribute", http.MethodGet, http.Header{"Content-Type": {"application/json"}}, bytes.NewBufferString(`{"slice": [1, 2, 3]}`), "", baseCtx, `
-			method = req.method
-			title = req.json_body.slice.foo
+			method = request.method
+			title = request.json_body.slice.foo
 		`, http.Header{"method": {http.MethodGet}}},
 		{"Variables / GET /w json body & null value", http.MethodGet, http.Header{"Content-Type": {"application/json"}}, bytes.NewBufferString(`{"json": null}`), "", baseCtx, `
-			method = req.method
-			title = req.json_body.json
+			method = request.method
+			title = request.json_body.json
 		`, http.Header{"method": {http.MethodGet}, "title": nil}},
 	}
 
diff --git a/eval/lib/jwt_test.go b/eval/lib/jwt_test.go
index e3406d6e..a693bd12 100644
--- a/eval/lib/jwt_test.go
+++ b/eval/lib/jwt_test.go
@@ -371,8 +371,8 @@ func TestJwtSignDynamic(t *testing.T) {
 					key = "$3cRe4"
 					ttl = "1h"
 					claims = {
-						x-method = req.method
-						x-status = beresp.status
+						x-method = request.method
+						x-status = backend_responses.default.status
 						exp = 1234567890
 					}
 				}
@@ -394,8 +394,8 @@ func TestJwtSignDynamic(t *testing.T) {
 					key = "$3cRe4"
 					ttl = "60.6s"
 					claims = {
-						x-method = req.method
-						x-status = beresp.status
+						x-method = request.method
+						x-status = backend_responses.default.status
 					}
 				}
 			}
diff --git a/handler/endpoint_test.go b/handler/endpoint_test.go
index d3351513..ebbd68d2 100644
--- a/handler/endpoint_test.go
+++ b/handler/endpoint_test.go
@@ -53,14 +53,14 @@ func TestEndpoint_RoundTrip_Eval(t *testing.T) {
 	logger := log.WithContext(context.Background())
 
 	tests := []testCase{
-		{"GET use req.Header", `
+		{"GET use request.Header", `
 		set_response_headers = {
-			X-Method = req.method
+			X-Method = request.method
 		}`, http.MethodGet, nil, header{"X-Method": http.MethodGet}},
-		{"POST use req.form_body", `
+		{"POST use request.form_body", `
 		set_response_headers = {
-			X-Method = req.method
-			X-Form_Body = req.form_body.foo
+			X-Method = request.method
+			X-Form_Body = request.form_body.foo
 		}`, http.MethodPost, strings.NewReader(`foo=bar`), header{
 			"X-Method":    http.MethodPost,
 			"X-Form_Body": "bar",
@@ -164,17 +164,17 @@ func TestEndpoint_RoundTripContext_Variables_json_body(t *testing.T) {
 		{"method /w body", `
 		origin = "` + origin.URL + `"
 		set_request_headers = {
-			x-test = req.json_body.foo
+			x-test = request.json_body.foo
 		}`, defaultMethods, test.Header{"Content-Type": "application/json"}, `{"foo": "bar"}`, want{req: test.Header{"x-test": "bar"}}},
 		{"method /w body", `
 		origin = "` + origin.URL + `"
 		set_request_headers = {
-			x-test = req.json_body.foo
+			x-test = request.json_body.foo
 		}`, []string{http.MethodTrace, http.MethodHead}, test.Header{"Content-Type": "application/json"}, `{"foo": "bar"}`, want{req: test.Header{"x-test": ""}}},
 		{"method /wo body", `
 		origin = "` + origin.URL + `"
 		set_request_headers = {
-			x-test = req.json_body.foo
+			x-test = request.json_body.foo
 		}`, append(defaultMethods, http.MethodTrace),
 			test.Header{"Content-Type": "application/json"}, "", want{req: test.Header{"x-test": ""}}},
 	}
@@ -258,16 +258,16 @@ func TestEndpoint_RoundTripContext_Null_Eval(t *testing.T) {
 
 	for _, tc := range []testCase{
 		{"no eval", `path = "/"`, test.Header{}},
-		{"json_body client field", `set_response_headers = { "x-client" = "my-val-x-${req.json_body.client}" }`,
+		{"json_body client field", `set_response_headers = { "x-client" = "my-val-x-${request.json_body.client}" }`,
 			test.Header{
 				"x-client": "my-val-x-true",
 			}},
 		{"json_body non existing field", `set_response_headers = {
-"${beresp.json_body.not-there}" = "my-val-0-${beresp.json_body.origin}"
-"${req.json_body.client}-my-val-a" = "my-val-b-${beresp.json_body.client}"
+"${backend_responses.default.json_body.not-there}" = "my-val-0-${backend_responses.default.json_body.origin}"
+"${request.json_body.client}-my-val-a" = "my-val-b-${backend_responses.default.json_body.client}"
 }`,
 			test.Header{"true-my-val-a": ""}}, // since one reference is failing ('not-there') the whole block does
-		{"json_body null value", `set_response_headers = { "x-null" = "${beresp.json_body.nil}" }`, test.Header{"x-null": ""}},
+		{"json_body null value", `set_response_headers = { "x-null" = "${backend_responses.default.json_body.nil}" }`, test.Header{"x-null": ""}},
 	} {
 		t.Run(tc.name, func(st *testing.T) {
 			h := test.New(st)
diff --git a/handler/transport/backend_test.go b/handler/transport/backend_test.go
index 38ba9dd6..f3f4953c 100644
--- a/handler/transport/backend_test.go
+++ b/handler/transport/backend_test.go
@@ -384,16 +384,16 @@ func TestProxy_BufferingOptions(t *testing.T) {
 
 	for i, tc := range []testCase{
 		{"no buffering", nil, `path = "/"`, eval.BufferNone},
-		{"req buffer json.body", nil, `path = "/${req.json_body.client}"`, eval.BufferRequest},
-		{"beresp buffer json.body", nil, `response_headers = { x-test = "${beresp.json_body.origin}" }`, eval.BufferResponse},
+		{"req buffer json.body", nil, `path = "/${request.json_body.client}"`, eval.BufferRequest},
+		{"beresp buffer json.body", nil, `response_headers = { x-test = "${backend_responses.default.json_body.origin}" }`, eval.BufferResponse},
 		{"bereq/beresp validation", newOptions(), `path = "/"`, eval.BufferRequest | eval.BufferResponse},
 		{"beresp validation", newOptions(), `path = "/"`, eval.BufferResponse},
 		{"bereq validation", newOptions(), `path = "/"`, eval.BufferRequest},
 		{"no validation", newOptions(), `path = "/"`, eval.BufferNone},
-		{"req buffer json.body & beresp validation", newOptions(), `set_response_headers = { x-test = "${req.json_body.client}" }`, eval.BufferRequest | eval.BufferResponse},
-		{"beresp buffer json.body & bereq validation", newOptions(), `set_response_headers = { x-test = "${beresp.json_body.origin}" }`, eval.BufferRequest | eval.BufferResponse},
-		{"req buffer json.body & bereq validation", newOptions(), `set_response_headers = { x-test = "${req.json_body.client}" }`, eval.BufferRequest},
-		{"beresp buffer json.body & beresp validation", newOptions(), `set_response_headers = { x-test = "${beresp.json_body.origin}" }`, eval.BufferResponse},
+		{"req buffer json.body & beresp validation", newOptions(), `set_response_headers = { x-test = "${request.json_body.client}" }`, eval.BufferRequest | eval.BufferResponse},
+		{"beresp buffer json.body & bereq validation", newOptions(), `set_response_headers = { x-test = "${backend_responses.default.json_body.origin}" }`, eval.BufferRequest | eval.BufferResponse},
+		{"req buffer json.body & bereq validation", newOptions(), `set_response_headers = { x-test = "${request.json_body.client}" }`, eval.BufferRequest},
+		{"beresp buffer json.body & beresp validation", newOptions(), `set_response_headers = { x-test = "${backend_responses.default.json_body.origin}" }`, eval.BufferResponse},
 	} {
 		t.Run(tc.name, func(st *testing.T) {
 			h := test.New(st)
diff --git a/server/testdata/endpoints/01_couper.hcl b/server/testdata/endpoints/01_couper.hcl
index bcb11b49..ed17c299 100644
--- a/server/testdata/endpoints/01_couper.hcl
+++ b/server/testdata/endpoints/01_couper.hcl
@@ -38,9 +38,9 @@ server "api" {
       }
 
       response {
-        status = "${beresp.status}" # string type test
+        status = "${backend_responses.default.status}" # string type test
 		# 404 + 404 + 404 + 404
-        body = beresps.r1.status + beresps.default.status + beresps.r2.status + beresps.p2.status
+        body = backend_responses.r1.status + backend_responses.default.status + backend_responses.r2.status + backend_responses.p2.status
       }
     }
   }
diff --git a/server/testdata/endpoints/03_couper.hcl b/server/testdata/endpoints/03_couper.hcl
index 50c1eaa9..e96c4c1c 100644
--- a/server/testdata/endpoints/03_couper.hcl
+++ b/server/testdata/endpoints/03_couper.hcl
@@ -5,7 +5,7 @@ server "backends" {
         backend {
           origin = env.COUPER_TEST_BACKEND_ADDR
 
-          basic_auth = "${req.headers.x-user}:pass"
+          basic_auth = "${request.headers.x-user}:pass"
         }
       }
     }
diff --git a/server/testdata/endpoints/04_couper.hcl b/server/testdata/endpoints/04_couper.hcl
index ea2dcaf8..7eb720fe 100644
--- a/server/testdata/endpoints/04_couper.hcl
+++ b/server/testdata/endpoints/04_couper.hcl
@@ -7,11 +7,11 @@ server "api" {
     endpoint "/" {
       proxy {
         backend {
-          origin = "${req.headers.x-origin}"
+          origin = "${request.headers.x-origin}"
 		  path   = "/resource"
 
 		  oauth2 {
-            token_endpoint = "${req.headers.x-token-endpoint}/oauth2"
+            token_endpoint = "${request.headers.x-token-endpoint}/oauth2"
             client_id      = "user"
             client_secret  = "pass"
             grant_type     = "client_credentials"
@@ -23,7 +23,7 @@ server "api" {
     endpoint "/2nd" {
       proxy {
         backend {
-          origin = "${req.headers.x-origin}"
+          origin = "${request.headers.x-origin}"
           path   = "/resource"
 
           oauth2 {
@@ -31,7 +31,7 @@ server "api" {
             client_secret  = "pass"
             grant_type     = "client_credentials"
             backend {
-              origin = "${req.headers.x-token-endpoint}"
+              origin = "${request.headers.x-token-endpoint}"
               path = "/oauth2"
             }
           }
diff --git a/server/testdata/endpoints/06_couper.hcl b/server/testdata/endpoints/06_couper.hcl
index 92c95945..969c0bd1 100644
--- a/server/testdata/endpoints/06_couper.hcl
+++ b/server/testdata/endpoints/06_couper.hcl
@@ -9,7 +9,7 @@ server "request-limit" {
       request_body_limit = "1"
       response {
         status = 204
-        body = req.json_body
+        body = request.json_body
       }
     }
   }
diff --git a/server/testdata/endpoints/07_couper.hcl b/server/testdata/endpoints/07_couper.hcl
index 22e9c297..9b102ef6 100644
--- a/server/testdata/endpoints/07_couper.hcl
+++ b/server/testdata/endpoints/07_couper.hcl
@@ -7,7 +7,7 @@ server "protected" {
     endpoint "/{path}" {
       proxy {
         backend {
-          path   = req.path_params.path
+          path   = request.path_params.path
           origin = env.COUPER_TEST_BACKEND_ADDR
         }
       }
diff --git a/server/testdata/integration/api/06_couper.hcl b/server/testdata/integration/api/06_couper.hcl
index 0ce8ae53..007267e7 100644
--- a/server/testdata/integration/api/06_couper.hcl
+++ b/server/testdata/integration/api/06_couper.hcl
@@ -6,7 +6,7 @@ server "multi-api" {
       proxy {
         backend {
           origin = env.COUPER_TEST_BACKEND_ADDR
-          path_prefix = "/${req.headers.x-val}/xxx/"
+          path_prefix = "/${request.headers.x-val}/xxx/"
         }
       }
     }
@@ -15,7 +15,7 @@ server "multi-api" {
       proxy {
         backend {
           origin = env.COUPER_TEST_BACKEND_ADDR
-          path_prefix = "/${req.headers.x-val}/xxx/"
+          path_prefix = "/${request.headers.x-val}/xxx/"
         }
       }
     }
@@ -24,7 +24,7 @@ server "multi-api" {
         backend {
           origin = env.COUPER_TEST_BACKEND_ADDR
           path = "/api/**"
-          path_prefix = "/${req.headers.x-val}/xxx/"
+          path_prefix = "/${request.headers.x-val}/xxx/"
         }
       }
     }
diff --git a/server/testdata/integration/config/03_couper.hcl b/server/testdata/integration/config/03_couper.hcl
index 68aec2aa..16d212b6 100644
--- a/server/testdata/integration/config/03_couper.hcl
+++ b/server/testdata/integration/config/03_couper.hcl
@@ -24,7 +24,7 @@ server "acs" {
         backend "test" {
           set_request_headers = {
             auth = ["ba1", "ba2"]
-            Authorization = req.headers.authorization # proxy blacklist
+            Authorization = request.headers.authorization # proxy blacklist
           }
         }
       }
@@ -67,7 +67,7 @@ server "acs" {
       backend "test" {
         set_request_headers = {
           auth = ["ba1", "ba4"]
-          Authorization = req.headers.authorization # proxy blacklist
+          Authorization = request.headers.authorization # proxy blacklist
         }
       }
     }
@@ -78,7 +78,7 @@ server "acs" {
     access_control = ["JWTToken"]
     response {
       headers = {
-        x-jwt-sub = req.ctx.JWTToken.sub
+        x-jwt-sub = request.context.JWTToken.sub
       }
     }
   }
@@ -107,7 +107,7 @@ definitions {
     origin = env.COUPER_TEST_BACKEND_ADDR
     path = "/anything"
     set_request_headers = {
-      Authorization: req.headers.authorization
+      Authorization: request.headers.authorization
     }
   }
 }
diff --git a/server/testdata/integration/endpoint_eval/01_couper.hcl b/server/testdata/integration/endpoint_eval/01_couper.hcl
index 5fc1b4c5..5615e9de 100644
--- a/server/testdata/integration/endpoint_eval/01_couper.hcl
+++ b/server/testdata/integration/endpoint_eval/01_couper.hcl
@@ -9,10 +9,10 @@ server "api" {
       proxy {
         backend "anything" {
           path = "/anything"
-          origin = "http://${req.path_params.origin}"
-          hostname = req.path_params.hostname
+          origin = "http://${request.path_params.origin}"
+          hostname = request.path_params.hostname
           set_response_headers = {
-            x-origin = req.path_params.origin
+            x-origin = request.path_params.origin
           }
         }
       }
diff --git a/server/testdata/integration/endpoint_eval/04_couper.hcl b/server/testdata/integration/endpoint_eval/04_couper.hcl
index b3197b06..92e906a1 100644
--- a/server/testdata/integration/endpoint_eval/04_couper.hcl
+++ b/server/testdata/integration/endpoint_eval/04_couper.hcl
@@ -3,26 +3,26 @@ server "api" {
     endpoint "/" {
       proxy {
         backend "anything" {
-          remove_query_params = [ "aeb_del", "CaseIns", req.headers.xyz ]
+          remove_query_params = [ "aeb_del", "CaseIns", request.headers.xyz ]
           set_query_params = {
             aeb_string = "str"
             aeb_multi = ["str1", "str2"]
             aeb_a_and_b = "A&B"
-            aeb_noop = req.query.noop
+            aeb_noop = request.query.noop
             aeb_null = null
             aeb_empty = ""
             xxx = ["yyy", "xxx"]
             xxx = ["aaa", "bbb"]
-            "${req.headers.aeb}" = "aeb"
+            "${request.headers.aeb}" = "aeb"
           }
           add_query_params = {
             aeb_string = "str"
             aeb_multi = ["str3", "str4"]
             aeb_a_and_b = "A&B"
-            aeb_noop = req.query.noop
+            aeb_noop = request.query.noop
             aeb_null = null
             aeb_empty = ""
-            "${req.headers.aeb}" = "aeb"
+            "${request.headers.aeb}" = "aeb"
           }
         }
       }
@@ -32,21 +32,21 @@ server "api" {
         ae_string = "str"
         ae_multi = ["str1", "str2"]
         ae_a_and_b = "A&B"
-        ae_noop = req.query.noop
+        ae_noop = request.query.noop
         ae_null = null
         ae_empty = ""
         xxx = "zzz"
-        "${req.headers.ae}" = "ae"
+        "${request.headers.ae}" = "ae"
       }
       add_query_params = {
         ae_string = "str"
         ae_multi = ["str3", "str4"]
         ae_a_and_b = "A&B"
-        ae_noop = req.query.noop
+        ae_noop = request.query.noop
         ae_null = null
         ae_empty = ""
         xxx = "ccc"
-        "${req.headers.ae}" = "ae"
+        "${request.headers.ae}" = "ae"
       }
     }
   }
@@ -62,7 +62,7 @@ server "api" {
 #         feb_string = "str"
 #         feb_multi = ["str1", "str2"]
 #         feb_a_and_b = "A&B"
-#         feb_noop = req.query.noop
+#         feb_noop = request.query.noop
 #         feb_null = null
 #         feb_empty = ""
 #       }
@@ -70,7 +70,7 @@ server "api" {
 #         feb_string = "str"
 #         feb_multi = ["str3", "str4"]
 #         feb_a_and_b = "A&B"
-#         feb_noop = req.query.noop
+#         feb_noop = request.query.noop
 #         feb_null = null
 #         feb_empty = ""
 #       }
@@ -81,7 +81,7 @@ server "api" {
 #       fe_String = "str"
 #       fe_multi = ["str1", "str2"]
 #       fe_a_and_b = "A&B"
-#       fe_noop = req.query.noop
+#       fe_noop = request.query.noop
 #       fe_null = null
 #       fe_empty = ""
 #     }
@@ -89,7 +89,7 @@ server "api" {
 #       fe_String = "str"
 #       fe_multi = ["str3", "str4"]
 #       fe_a_and_b = "A&B"
-#       fe_noop = req.query.noop
+#       fe_noop = request.query.noop
 #       fe_null = null
 #       fe_empty = ""
 #     }
@@ -106,22 +106,22 @@ definitions {
       def_string = "str"
       def_multi = ["str1", "str2"]
       def_a_and_b = "A&B"
-      def_noop = req.query.noop
+      def_noop = request.query.noop
       def_null = null
       def_empty = ""
       xxx = "ddd"
-      "${req.headers.def}" = "def"
-      foo = req.headers.foo
+      "${request.headers.def}" = "def"
+      foo = request.headers.foo
     }
     add_query_params = {
       def_string = "str"
       def_multi = ["str3", "str4"]
       def_a_and_b = "A&B"
-      def_noop = req.query.noop
+      def_noop = request.query.noop
       def_null = null
       def_empty = ""
       xxx = "eee"
-      "${req.headers.def}" = "def"
+      "${request.headers.def}" = "def"
     }
   }
 }
diff --git a/server/testdata/integration/endpoint_eval/08_couper.hcl b/server/testdata/integration/endpoint_eval/08_couper.hcl
index 81720402..e8008e4b 100644
--- a/server/testdata/integration/endpoint_eval/08_couper.hcl
+++ b/server/testdata/integration/endpoint_eval/08_couper.hcl
@@ -9,10 +9,10 @@ server "protected" {
       proxy {
         backend "anything" {
           path = "/anything"
-          origin = "http://${req.path_params.origin}"
-          hostname = req.path_params.hostname
+          origin = "http://${request.path_params.origin}"
+          hostname = request.path_params.hostname
           set_response_headers = {
-            x-origin = req.path_params.origin
+            x-origin = request.path_params.origin
           }
           openapi {
             file = "08_schema.yaml"
diff --git a/server/testdata/integration/endpoint_eval/12_couper.hcl b/server/testdata/integration/endpoint_eval/12_couper.hcl
index d31baad2..14dde8ca 100644
--- a/server/testdata/integration/endpoint_eval/12_couper.hcl
+++ b/server/testdata/integration/endpoint_eval/12_couper.hcl
@@ -3,26 +3,26 @@ server "api" {
     endpoint "/" {
       proxy {
         backend "anything" {
-          remove_request_headers = [ "aeb_del", "CaseIns", req.query.xyz[0] ]
+          remove_request_headers = [ "aeb_del", "CaseIns", request.query.xyz[0] ]
           set_request_headers = {
             aeb_string = "str"
             aeb_multi = ["str1", "str2"]
             aeb_a_and_b = "A&B"
-            aeb_noop = req.headers.noop
+            aeb_noop = request.headers.noop
             aeb_null = null
             aeb_empty = ""
             xxx = ["yyy", "xxx"]
             xxx = ["aaa", "bbb"]
-            "${req.query.aeb[0]}" = "aeb"
+            "${request.query.aeb[0]}" = "aeb"
           }
           add_request_headers = {
             aeb_string = "str"
            aeb_multi = ["str3", "str4"]
             aeb_a_and_b = "A&B"
-            aeb_noop = req.headers.noop
+            aeb_noop = request.headers.noop
             aeb_null = null
             aeb_empty = ""
-            "${req.query.aeb[0]}" = "aeb"
+            "${request.query.aeb[0]}" = "aeb"
           }
 
           remove_response_headers = [ "Remove-Me-2" ]
@@ -48,22 +48,22 @@ definitions {
       def_string = "str"
       def_multi = ["str1", "str2"]
       def_a_and_b = "A&B"
-      def_noop = req.headers.noop
+      def_noop = request.headers.noop
       def_null = null
       def_empty = ""
       xxx = "ddd"
-      "${req.query.def[0]}" = "def"
-      foo = req.query.foo[0]
+      "${request.query.def[0]}" = "def"
+      foo = request.query.foo[0]
     }
     add_request_headers = {
       def_string = "str"
       def_multi = ["str3", "str4"]
       def_a_and_b = "A&B"
-      def_noop = req.headers.noop
+      def_noop = request.headers.noop
       def_null = null
       def_empty = ""
       xxx = "eee"
-      "${req.query.def[0]}" = "def"
+      "${request.query.def[0]}" = "def"
     }
 
     remove_response_headers = [ "remove-me-1" ]
diff --git a/server/testdata/integration/endpoint_eval/13_couper.hcl b/server/testdata/integration/endpoint_eval/13_couper.hcl
index d20daab2..06bf8330 100644
--- a/server/testdata/integration/endpoint_eval/13_couper.hcl
+++ b/server/testdata/integration/endpoint_eval/13_couper.hcl
@@ -1,12 +1,12 @@
 server "dynamic-request" {
   endpoint "/**" {
     request {
-      url    = "${env.COUPER_TEST_BACKEND_ADDR}/anything?q=${req.headers.query}"
-      body   = req.headers.body
-      method = req.query.method[0]
+      url    = "${env.COUPER_TEST_BACKEND_ADDR}/anything?q=${request.headers.query}"
+      body   = request.headers.body
+      method = request.query.method[0]
 
       headers = {
-        Test = req.headers.test
+        Test = request.headers.test
       }
 
       backend {
diff --git a/server/testdata/integration/endpoint_eval/14_couper.hcl b/server/testdata/integration/endpoint_eval/14_couper.hcl
index 112af5ce..b9d7984a 100644
--- a/server/testdata/integration/endpoint_eval/14_couper.hcl
+++ b/server/testdata/integration/endpoint_eval/14_couper.hcl
@@ -99,7 +99,7 @@ server "bodies" {
   endpoint "/request/json_body/dyn" {
     request {
       url = "${env.COUPER_TEST_BACKEND_ADDR}/anything"
-      json_body = req.json_body
+      json_body = request.json_body
 
       backend {
         origin = env.COUPER_TEST_BACKEND_ADDR
@@ -138,7 +138,7 @@ server "bodies" {
   endpoint "/request/form_body/dyn" {
     request {
       url = "${env.COUPER_TEST_BACKEND_ADDR}/anything"
-      form_body = req.form_body
+      form_body = request.form_body
 
       backend {
         origin = env.COUPER_TEST_BACKEND_ADDR
diff --git a/server/testdata/integration/endpoint_eval/15_couper.hcl b/server/testdata/integration/endpoint_eval/15_couper.hcl
index 9a8d887a..6e58351b 100644
--- a/server/testdata/integration/endpoint_eval/15_couper.hcl
+++ b/server/testdata/integration/endpoint_eval/15_couper.hcl
@@ -2,7 +2,7 @@ server "bodies" {
   endpoint "/req" {
     response {
       status = 200
-      json_body = req
+      json_body = request
     }
   }
 }