问题描述
我试图使用Mountebank传递路径参数。
下面的方法可以使用,但是路径是静态的,没有任何参数。
"predicates": [
{
"equals": {
"method": "GET","path": "/accounts","query": {
"permissionId": "xxx"
}
}
}
],"responses": [
{
..... }
]
如果我需要在GET /accounts/[account-no]
是参数的情况下进行account-no
解决方法
以下正则表达式有效,请注意,如果使用正则表达式,请使用matches
代替equal
"predicates": [
{
"matches": {
"method": "GET","path": "/accounts/\\d+","query": {
"permissionId": "xxx"
}
}
}
],"responses": [
{
..... }
]