谓词值可以在 Mountebank 中使用通配符吗?
Can predicate values have wildcards in Mountebank?
我正在尝试定义存根:
{
"predicates":[
{
"equals":{
"method":"GET",
"path":"/sword/eBISXMLInvoice2.do",
"query": {
"action": "index",
"page": 3 <-- this one!
}
}
}
],
"responses":[
{
"is":{
"statusCode":200,
"headers":{
"Content-Type":"application/xml"
},
"body":"<doclist><document uuid='101654' type='invoice' date='2018-11-14 13:49:43' /></doclist>"
}
}
]
}
其中一个预期的查询字符串参数(称为 "page")可以有多个值。我如何定义谓词来处理这个问题?
我的问题其实很容易回答。根据 docs,"equals" 谓词,如果任何值匹配 , 将匹配。
全文:
On occasion you may encounter multi-valued keys. This can be the case
with querystrings and HTTP headers that have repeating keys, for
example ?key=first&key=second
. In those cases, deepEquals will
require all the values (in any order) to match. All other predicates
will match if any value matches, so an equals predicate will match
with the value of second
in the example above.
所以我可以只从谓词中删除可变查询字符串值,或者我可以将它保留在那里,没关系。
{
"equals":{
"method":"GET",
"path":"/sword/eBISXMLInvoice2.do",
"query": {
"action": "index"
}
}
}
我正在尝试定义存根:
{
"predicates":[
{
"equals":{
"method":"GET",
"path":"/sword/eBISXMLInvoice2.do",
"query": {
"action": "index",
"page": 3 <-- this one!
}
}
}
],
"responses":[
{
"is":{
"statusCode":200,
"headers":{
"Content-Type":"application/xml"
},
"body":"<doclist><document uuid='101654' type='invoice' date='2018-11-14 13:49:43' /></doclist>"
}
}
]
}
其中一个预期的查询字符串参数(称为 "page")可以有多个值。我如何定义谓词来处理这个问题?
我的问题其实很容易回答。根据 docs,"equals" 谓词,如果任何值匹配 , 将匹配。
全文:
On occasion you may encounter multi-valued keys. This can be the case with querystrings and HTTP headers that have repeating keys, for example
?key=first&key=second
. In those cases, deepEquals will require all the values (in any order) to match. All other predicates will match if any value matches, so an equals predicate will match with the value ofsecond
in the example above.
所以我可以只从谓词中删除可变查询字符串值,或者我可以将它保留在那里,没关系。
{
"equals":{
"method":"GET",
"path":"/sword/eBISXMLInvoice2.do",
"query": {
"action": "index"
}
}
}