2020-05-15 05:53:28 +08:00
|
|
|
:80 {
|
|
|
|
@matcher {
|
|
|
|
method GET
|
|
|
|
}
|
|
|
|
respond @matcher "get"
|
|
|
|
|
|
|
|
@matcher2 method POST
|
|
|
|
respond @matcher2 "post"
|
|
|
|
|
|
|
|
@matcher3 not method PUT
|
|
|
|
respond @matcher3 "not put"
|
2020-09-26 07:50:26 +08:00
|
|
|
|
|
|
|
@matcher4 vars "{http.request.uri}" "/vars-matcher"
|
|
|
|
respond @matcher4 "from vars matcher"
|
|
|
|
|
|
|
|
@matcher5 vars_regexp static "{http.request.uri}" `\.([a-f0-9]{6})\.(css|js)$`
|
|
|
|
respond @matcher5 "from vars_regexp matcher with name"
|
|
|
|
|
|
|
|
@matcher6 vars_regexp "{http.request.uri}" `\.([a-f0-9]{6})\.(css|js)$`
|
|
|
|
respond @matcher6 "from vars_regexp matcher without name"
|
2020-11-01 00:27:01 +08:00
|
|
|
|
|
|
|
@matcher7 {
|
|
|
|
header Foo bar
|
|
|
|
header Foo foobar
|
|
|
|
header Bar foo
|
|
|
|
}
|
|
|
|
respond @matcher7 "header matcher merging values of the same field"
|
2020-11-03 07:05:01 +08:00
|
|
|
|
|
|
|
@matcher8 {
|
|
|
|
query foo=bar foo=baz bar=foo
|
|
|
|
query bar=baz
|
|
|
|
}
|
|
|
|
respond @matcher8 "query matcher merging pairs with the same keys"
|
2020-12-10 02:28:14 +08:00
|
|
|
|
|
|
|
@matcher9 {
|
|
|
|
header !Foo
|
|
|
|
header Bar foo
|
|
|
|
}
|
|
|
|
respond @matcher9 "header matcher with null field matcher"
|
2020-05-15 05:53:28 +08:00
|
|
|
}
|
|
|
|
----------
|
|
|
|
{
|
|
|
|
"apps": {
|
|
|
|
"http": {
|
|
|
|
"servers": {
|
|
|
|
"srv0": {
|
|
|
|
"listen": [
|
|
|
|
":80"
|
|
|
|
],
|
|
|
|
"routes": [
|
|
|
|
{
|
|
|
|
"match": [
|
|
|
|
{
|
|
|
|
"method": [
|
|
|
|
"GET"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"handle": [
|
|
|
|
{
|
|
|
|
"body": "get",
|
|
|
|
"handler": "static_response"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"match": [
|
|
|
|
{
|
|
|
|
"method": [
|
|
|
|
"POST"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"handle": [
|
|
|
|
{
|
|
|
|
"body": "post",
|
|
|
|
"handler": "static_response"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"match": [
|
|
|
|
{
|
|
|
|
"not": [
|
|
|
|
{
|
|
|
|
"method": [
|
|
|
|
"PUT"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"handle": [
|
|
|
|
{
|
|
|
|
"body": "not put",
|
|
|
|
"handler": "static_response"
|
|
|
|
}
|
|
|
|
]
|
2020-09-26 07:50:26 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"match": [
|
|
|
|
{
|
|
|
|
"vars": {
|
|
|
|
"{http.request.uri}": "/vars-matcher"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"handle": [
|
|
|
|
{
|
|
|
|
"body": "from vars matcher",
|
|
|
|
"handler": "static_response"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"match": [
|
|
|
|
{
|
|
|
|
"vars_regexp": {
|
|
|
|
"{http.request.uri}": {
|
|
|
|
"name": "static",
|
|
|
|
"pattern": "\\.([a-f0-9]{6})\\.(css|js)$"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"handle": [
|
|
|
|
{
|
|
|
|
"body": "from vars_regexp matcher with name",
|
|
|
|
"handler": "static_response"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"match": [
|
|
|
|
{
|
|
|
|
"vars_regexp": {
|
|
|
|
"{http.request.uri}": {
|
|
|
|
"pattern": "\\.([a-f0-9]{6})\\.(css|js)$"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"handle": [
|
|
|
|
{
|
|
|
|
"body": "from vars_regexp matcher without name",
|
|
|
|
"handler": "static_response"
|
|
|
|
}
|
|
|
|
]
|
2020-11-01 00:27:01 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"match": [
|
|
|
|
{
|
|
|
|
"header": {
|
|
|
|
"Bar": [
|
|
|
|
"foo"
|
|
|
|
],
|
|
|
|
"Foo": [
|
|
|
|
"bar",
|
|
|
|
"foobar"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"handle": [
|
|
|
|
{
|
|
|
|
"body": "header matcher merging values of the same field",
|
|
|
|
"handler": "static_response"
|
|
|
|
}
|
|
|
|
]
|
2020-11-03 07:05:01 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"match": [
|
|
|
|
{
|
|
|
|
"query": {
|
|
|
|
"bar": [
|
|
|
|
"foo",
|
|
|
|
"baz"
|
|
|
|
],
|
|
|
|
"foo": [
|
|
|
|
"bar",
|
|
|
|
"baz"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"handle": [
|
|
|
|
{
|
|
|
|
"body": "query matcher merging pairs with the same keys",
|
|
|
|
"handler": "static_response"
|
|
|
|
}
|
|
|
|
]
|
2020-12-10 02:28:14 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"match": [
|
|
|
|
{
|
|
|
|
"header": {
|
|
|
|
"Bar": [
|
|
|
|
"foo"
|
|
|
|
],
|
|
|
|
"Foo": null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"handle": [
|
|
|
|
{
|
|
|
|
"body": "header matcher with null field matcher",
|
|
|
|
"handler": "static_response"
|
|
|
|
}
|
|
|
|
]
|
2020-05-15 05:53:28 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|