Mock转发规则应用


1、配置转发规则

Mock转发规则:

选择配置Mock转发规则的子项目,在“资源管理”->“Mock转发规则”中配置。如在“用户手册”->“用法示例”->“Mock示例”中配置转发规则:https://www.163.com,配置的转发规则仅对当前子项目生效。

2、转发规则应用

接口:GET /mock-test Mock信息:

MockURL:http://mock-gotest.hz.netease.com/27ac026779613da81e1f23d67cff3a3f/mock-test

Mock名称 匹配规则 响应体
Mock正常请求(默认) moduleid=7458(URL) {"code":200,"msg":"ok"}
Mock签名校验失败 moduleid=1753(URL) {"code":"301","msg":"签名检验失败"}

(1)无转发规则

  • URL参数入参为moduleid=1753,则请求为:http://mock-gotest.hz.netease.com/27ac026779613da81e1f23d67cff3a3f/mock-test?moduleid=1753 响应为:{"code":"301","msg":"签名检验失败"}

  • URL参数入参为moduleid=7458,则请求为:http://mock-gotest.hz.netease.com/27ac026779613da81e1f23d67cff3a3f/mock-test?moduleid=7458 响应为:{"code":200,"msg":"ok"}

  • URL参数入参为其它参数,则请求为定义的默认的Mock请求。

(2)有转发规则

  • 定义所有的Mock接口匹配规则匹配失败时,则请求转发。如在URL入参为apiId=1754,则请求为https://www.163.com/mock-test?apiId=1754
Copyright © GoApi 2018 all right reserved,powered by Gitbook该文件修订时间: 2023-08-24 14:35:00

results matching ""

    No results matching ""