github.com/avenga/couper@v1.12.2/server/testdata/integration/endpoint_eval/20_couper.hcl (about)

     1  server "cty.NilVal" {
     2    endpoint "/1stchild" {
     3      proxy {
     4        url = "${env.COUPER_TEST_BACKEND_ADDR}/anything"
     5      }
     6      response {
     7        headers = {
     8          X-Value = env.COUPER_TEST_BACKEND_ADDR
     9          Z-Value = "y"
    10        }
    11      }
    12    }
    13  
    14    endpoint "/2ndchild/no" {
    15      proxy {
    16        url = "${env.COUPER_TEST_BACKEND_ADDR}/anything"
    17      }
    18      response {
    19        headers = {
    20          X-Value = env.COUPER_TEST_BACKEND_ADDR.not_there
    21          Z-Value = "y"
    22        }
    23      }
    24    }
    25  
    26    endpoint "/child-chain/no" {
    27      proxy {
    28        url = "${env.COUPER_TEST_BACKEND_ADDR}/anything"
    29      }
    30      response {
    31        headers = {
    32          X-Value = env.COUPER_TEST_BACKEND_ADDR.one.two
    33          Z-Value = "y"
    34        }
    35      }
    36    }
    37  
    38    endpoint "/list-idx" {
    39      proxy {
    40        url = "${env.COUPER_TEST_BACKEND_ADDR}/anything"
    41      }
    42      response {
    43        headers = {
    44          X-Value = backend_responses.default.json_body.JSON.list[1]
    45          Z-Value = "y"
    46        }
    47      }
    48    }
    49  
    50    endpoint "/list-idx-splat" {
    51      proxy {
    52        url = "${env.COUPER_TEST_BACKEND_ADDR}/anything"
    53      }
    54      response {
    55        headers = {
    56          X-Value = backend_responses.default.json_body.JSON.list[*]
    57          Z-Value = "y"
    58        }
    59      }
    60    }
    61  
    62    endpoint "/list-idx/no" {
    63      proxy {
    64        url = "${env.COUPER_TEST_BACKEND_ADDR}/anything"
    65      }
    66      response {
    67        headers = {
    68          X-Value = backend_responses.default.json_body.JSON.list[21]
    69          Z-Value = "y"
    70        }
    71      }
    72    }
    73  
    74    endpoint "/list-idx-chain/no" {
    75      proxy {
    76        url = "${env.COUPER_TEST_BACKEND_ADDR}/anything"
    77      }
    78      response {
    79        headers = {
    80          X-Value = backend_responses.default.json_body.JSON.list[21][12]
    81          Z-Value = "y"
    82        }
    83      }
    84    }
    85  
    86    endpoint "/list-idx-key-chain/no" {
    87      proxy {
    88        url = "${env.COUPER_TEST_BACKEND_ADDR}/anything"
    89      }
    90      response {
    91        headers = {
    92          X-Value = backend_responses.default.json_body.JSON.list[21].obj[1]
    93          Z-Value = "y"
    94        }
    95      }
    96    }
    97  
    98    endpoint "/root/no" {
    99      proxy {
   100        url = "${env.COUPER_TEST_BACKEND_ADDR}/anything"
   101      }
   102      response {
   103        headers = {
   104          X-Value = no-root
   105          Z-Value = "y"
   106        }
   107      }
   108    }
   109  
   110    endpoint "/tpl" {
   111      proxy {
   112        url = "${env.COUPER_TEST_BACKEND_ADDR}/anything"
   113      }
   114      response {
   115        headers = {
   116          X-Value = "${env.COUPER_TEST_BACKEND_ADDR}mytext"
   117          Z-Value = "y"
   118        }
   119      }
   120    }
   121  
   122    endpoint "/for" {
   123      proxy {
   124        url = "${env.COUPER_TEST_BACKEND_ADDR}/anything"
   125      }
   126      response {
   127        headers = {
   128          X-Value = [for i, v in backend_responses.default.json_body.JSON.list: v if i < 1]
   129          Z-Value = "y"
   130        }
   131      }
   132    }
   133  
   134    endpoint "/conditional/false" {
   135      response {
   136        headers = {
   137          X-Value = request.form_body.state != null ? request.form_body.state : "x"
   138          Z-Value = "y"
   139        }
   140      }
   141    }
   142  
   143    endpoint "/conditional/true" {
   144      response {
   145        headers = {
   146          X-Value = true ? request.form_body.state : "x"
   147          Z-Value = "y"
   148        }
   149      }
   150    }
   151  
   152    endpoint "/conditional/nested" {
   153      response {
   154        headers = {
   155          X-Value = request.form_body.state != (2 + 2 == 4 ? "value" : null) ? "x" : request.form_body.state
   156          Z-Value = "y"
   157        }
   158      }
   159    }
   160  
   161    endpoint "/conditional/nested/true" {
   162      response {
   163        headers = {
   164          X-Value = request.form_body.state == null ? 1 + 1 == 2 ? "x" : null : request.form_body.state
   165          Z-Value = "y"
   166        }
   167      }
   168    }
   169  
   170    endpoint "/conditional/nested/false" {
   171      response {
   172        headers = {
   173          X-Value = request.form_body.state != null ? null : 1+1 == 3 ? null : "x"
   174          Z-Value = "y"
   175        }
   176      }
   177    }
   178  
   179    endpoint "/functions/arg-items" {
   180      response {
   181        headers = {
   182          X-Value = json_encode(merge({ "obj": {"key": "val"} }, {
   183            foo = "bar"
   184            xxxx = request.context.granted_permissions
   185          }))
   186          Z-Value = "y"
   187        }
   188      }
   189    }
   190  
   191    endpoint "/functions/tuple-expr" {
   192      response {
   193        headers = {
   194          X-Value = json_encode({ "array": merge(["a"], ["b"]) })
   195          Z-Value = "y"
   196        }
   197      }
   198    }
   199  
   200    endpoint "/rte1" {
   201      response {
   202        # *hclsyntax.RelativeTraversalExpr
   203        headers = {
   204          X-Value = [0, 2, 4][1]
   205          Z-Value = "y"
   206        }
   207      }
   208    }
   209  
   210    endpoint "/rte2" {
   211      response {
   212        # *hclsyntax.RelativeTraversalExpr
   213        headers = {
   214          X-Value = {a = 2, b = 4}["a"]
   215          Z-Value = "y"
   216        }
   217      }
   218    }
   219  
   220    endpoint "/ie1" {
   221      response {
   222        # *hclsyntax.IndexExpr
   223        headers = {
   224          X-Value = [0, 2, 4][2 - 1]
   225          Z-Value = "y"
   226        }
   227      }
   228    }
   229  
   230    endpoint "/ie2" {
   231      response {
   232        # *hclsyntax.IndexExpr
   233        headers = {
   234          X-Value = {"/ie1" = 1, "/ie2" = 2}[request.path]
   235          Z-Value = "y"
   236        }
   237      }
   238    }
   239  
   240    endpoint "/uoe1" {
   241      response {
   242        # *hclsyntax.UnaryOpExpr
   243        headers = {
   244          X-Value = -2
   245          Z-Value = "y"
   246        }
   247      }
   248    }
   249  
   250    endpoint "/uoe2" {
   251      response {
   252        # *hclsyntax.UnaryOpExpr
   253        headers = {
   254          X-Value = json_encode(!false)
   255          Z-Value = "y"
   256        }
   257      }
   258    }
   259  
   260    endpoint "/bad/dereference/string" {
   261      response {
   262        headers = {
   263          X-Value = request.query.foo[0].ooops
   264          Z-Value = "y"
   265        }
   266      }
   267    }
   268  
   269    endpoint "/bad/dereference/array" {
   270      response {
   271        headers = {
   272          X-Value = request.query.foo.ooops
   273          Z-Value = "y"
   274        }
   275      }
   276    }
   277  
   278  
   279    endpoint "/conditional/null" {
   280      response {
   281        status = null ? 204 : 400
   282      }
   283    }
   284  
   285    endpoint "/conditional/string" {
   286      response {
   287        status = "foo" ? 204 : 400
   288      }
   289    }
   290  
   291    endpoint "/conditional/number" {
   292      response {
   293        status = 2 ? 204 : 400
   294      }
   295    }
   296  
   297    endpoint "/conditional/tuple" {
   298      response {
   299        status = [] ? 204 : 400
   300      }
   301    }
   302  
   303    endpoint "/conditional/object" {
   304      response {
   305        status = {} ? 204 : 400
   306      }
   307    }
   308  
   309    endpoint "/conditional/string/expr" {
   310      response {
   311        status = {"a": "foo"}.a ? 204 : 400
   312      }
   313    }
   314  
   315    endpoint "/conditional/number/expr" {
   316      response {
   317        status = {"a": 2}.a ? 204 : 400
   318      }
   319    }
   320  }
   321  
   322  settings {
   323    no_proxy_from_env = true
   324  }