forked from membrane/api-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapis.yaml
More file actions
71 lines (71 loc) · 2.13 KB
/
apis.yaml
File metadata and controls
71 lines (71 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# yaml-language-server: $schema=https://www.membrane-api.io/v7.1.2.json
api:
port: 2000
flow:
- request:
- if:
test: request.isJSON()
flow:
- log:
message: JSON Request!
- if:
test: $.name
language: jsonpath
flow:
- log:
message: The JSON request contains the key 'name' with the value 'foo'.
- if:
test: method == 'POST'
flow:
- log:
message: Request method was POST.
- if:
test: params?.param1?.[0] == 'value2'
flow:
- log:
message: Query Parameter Given!
- if:
test: headers['X-Test-Header'] != null and headers['X-Test-Header'] matches '.*bar.*'
flow:
- log:
message: X-Test-Header contains 'bar'
- if:
test: request.getBody.getLength gt 64
flow:
- log:
message: Long body
- if:
test: request.isXML()
flow:
- log:
message: XML Request!
- if:
test: //foo
language: xpath
flow:
- log:
message: Has foo element!
- response:
- if:
test: statusCode matches '[45]\d\d'
flow:
- template:
pretty: yes
contentType: application/json
src: |
{
"type": "https://membrane-api.io/error/",
"title": ${exc.response.statusMessage},
"status": ${exc.response.statusCode}
}
- if:
test: statusCode == 302
flow:
- groovy:
src: |
println("Status code changed")
exc.getResponse().setStatusCode(404)
- template:
src: Success
- return:
status: 302