标签:startup uri response div bubuko png chap 关键字 方法
首先在Chapter7文件夹下再新建一个startGet.json
startget.json代码如下,因为是get请求,所以要写method关键字,有两个,一个是有参数,一个是无参数的请求。
[ { "description":"模拟一个没有参数的get请求", "request":{ "uri":"/getDemo", "method":"get" }, "response":{ "text":"这是一个没有参数的get请求" } }, { "description":"模拟一个带参数的get请求", "request":{ "uri":"/getwithparam", "method":"get", "queries":{ "name":"huhanshan", "age":"18" } }, "response":{ "text":"这是一个带参数的get请求,胡汉山又回来了" } } ]
启动mock服务器; java -jar ./moco-runner-0.12.0-standalone.jar http -p 8888 -c startupGet.json
然后在浏览器访问:localhost:8888/getDemo 这是一个不带参数的请求
log:
然后也可以访问:http://localhost:8888/getwithparam?name=huhanshan&age=18 这是一个带参数的请求吧
log:
Mock2 moco框架的http协议get方法Mock的实现
标签:startup uri response div bubuko png chap 关键字 方法
原文地址:https://www.cnblogs.com/peiminer/p/9636356.html