不带参数的mock请求:
config.json
[
{
"description":"这是Mock接口的Demo",
"request":{
"uri":"/GetDemo",
"method":"get"
},
"response":{
"text":"First get request"
}
}
]
在命令行输入如下:

带开浏览器输入如下:http://localhost:8080/GetDemo
页面显示

后台命令行输出如下请求过程:

待参数的get请求
http://localhost:8080/GetDemoparam?name=Anndy&&age=18
[
{
"description":"这是Mock接口的Demo",
"request":{
"uri":"/GetDemoparam",
"method":"get",
"queries":{
"name":"Anndy",
"age":"18"
}
},
"response":{
"text":"This is Get request name=Anndy"
}
}
]

带cookie信息的get请求
新建cookie: login=true(新建的cookie键值对) ,path(路径)=/,domain(域)=localhost
[
{
"description":"This is a get request with cookies",
"request":{
"uri":"/getwithcookies",
"method":"get",
"cookies":{
"login":"true"
}
},
"response":{
"text":"This is a response with cookies"
}
}
]
博客介绍了mock请求相关内容,包含不带参数的mock请求,在命令行和浏览器中的操作及页面显示、后台输出情况。还提及带参数的get请求和带cookie信息的get请求,如带参数请求的URL及新建cookie的键值对、路径和域等。

被折叠的 条评论
为什么被折叠?



