简体   繁体   中英

Is there way to pass path parameter in Mountbank

I was trying to pass path parameter using Mountebank.

Below is working, but there path is static no any parameters.

"predicates": [
            {
              "equals": {
                "method": "GET",
                "path": "/accounts",
                "query": {
                  "permissionId": "xxx"
                }
              }
            }
          ],
          "responses": [
            {
              .....            }
          ]

In case if I need to do GET /accounts/[account-no] where account-no is a parameter

Below regex worked, Please note use matches in case of regex instead of equal

"predicates": [
            {
              "matches": {
                "method": "GET",
                "path": "/accounts/\\d+",
                "query": {
                  "permissionId": "xxx"
                }
              }
            }
          ],
          "responses": [
            {
              .....            }
          ]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM