github.com/avenga/couper@v1.12.2/server/testdata/integration/endpoint_eval/21_couper.hcl (about) 1 server { 2 api { 3 # from https://github.com/hashicorp/hcl/blob/main/hclsyntax/spec.md#for-expressions 4 endpoint "/for0" { 5 response { 6 json_body = [for v in ["a", "b"]: v] # ["a", "b"] 7 } 8 } 9 endpoint "/for1" { 10 response { 11 json_body = [for i, v in ["a", "b"]: i] # [0, 1] 12 } 13 } 14 endpoint "/for2" { 15 response { 16 json_body = {for i, v in ["a", "b"]: v => i} # {a = 0, b = 1} 17 } 18 } 19 endpoint "/for3" { 20 response { 21 json_body = {for i, v in ["a", "a", "b"]: v => i...} # {a = [0, 1], b = [2]} 22 } 23 } 24 endpoint "/for4" { 25 response { 26 json_body = [for i, v in ["a", "b", "c"]: v if i < 2] # ["a", "b"] 27 } 28 } 29 30 endpoint "/for5" { 31 response { 32 json_body = {for name in json_decode(request.headers.y): "${request.headers.z}-${name}" => request.headers[name]} 33 } 34 } 35 36 # currently error: Unsupported attribute; This object does not have an attribute named "notthere". 37 endpoint "/for6" { 38 response { 39 json_body = {for k, v in {}.notthere: k => v} 40 } 41 } 42 endpoint "/for7" { 43 response { 44 json_body = {for k in ["a", "b"]: {}.notthere[k] => k} 45 } 46 } 47 endpoint "/for8" { 48 response { 49 json_body = {for k in ["a", "b"]: k => {}.notthere[k]} 50 } 51 } 52 } 53 }