mock server 挡板服务搭建
2017-01-04 10:05
218 查看
官网:https://github.com/dreamhead/moco
启动moco服务
java -jar moco-runner-<version>-standalone.jar start -p 12306 -c foo.json
java -jar moco-runner-0.11.0-standalone.jar start -p 12306 -c foo.json
初始状态
{
"response" :
{
"text" : "Hello, Moco"
}
}
http://localhost:12306
带参数的 HTTP 请求
{
"request" :
{
"uri" : "/foo",
"queries" :
{
"param" : "blah"
}
},
"response" :
{
"text" : "bar"
}
}
http://localhost:12306/foo?param=blah
基于正则表达的 URL 匹配
{
"request":
{
"uri":
{
"match": "/\\w*/foo"
}
},
"response":
{
"text": "bar"
}
}
在地址栏输入多个地址(/foo 前带有任意字符, 比如 http://localhost:12306/xxx/foo)
跳转
{
"request" :
{
"uri" : "/redirect"
},
"redirectTo" : "http://www.baidu.com"
}
http://localhost:12306/redirect
返回 JSON 对象
{
"request": {
"uri": "/json"
},
"response": {
"json": {
"foo" : "bar"
}
}
}
http://localhost:12306/json
启动moco服务
java -jar moco-runner-<version>-standalone.jar start -p 12306 -c foo.json
java -jar moco-runner-0.11.0-standalone.jar start -p 12306 -c foo.json
初始状态
{
"response" :
{
"text" : "Hello, Moco"
}
}
http://localhost:12306
带参数的 HTTP 请求
{
"request" :
{
"uri" : "/foo",
"queries" :
{
"param" : "blah"
}
},
"response" :
{
"text" : "bar"
}
}
http://localhost:12306/foo?param=blah
基于正则表达的 URL 匹配
{
"request":
{
"uri":
{
"match": "/\\w*/foo"
}
},
"response":
{
"text": "bar"
}
}
在地址栏输入多个地址(/foo 前带有任意字符, 比如 http://localhost:12306/xxx/foo)
跳转
{
"request" :
{
"uri" : "/redirect"
},
"redirectTo" : "http://www.baidu.com"
}
http://localhost:12306/redirect
返回 JSON 对象
{
"request": {
"uri": "/json"
},
"response": {
"json": {
"foo" : "bar"
}
}
}
http://localhost:12306/json
相关文章推荐
- 使用LVS(Linux Virtual Server)在Linux上搭建负载均衡的集群服务
- 使用LVS(Linux Virtual Server)在Linux上搭建负载均衡的集群服务(DR模式
- Windows下使用FileZilla[Server+Client]搭建FTP服务
- 2-1-sshd-xinet-telnet服务服务搭建与管理(Red Hat Enterprise Linux Server6.3)
- (转)ubuntu 12.04搭建Adobe Flash Media Server服务
- Microsoft SQL Server 2005的分析服务 搭建数据仓库
- UbuntuServer14.04搭建Web服务
- FindFriendsServer服务搭建
- ffmpeg+ffserver媒体服务搭建小记
- Ubuntu Server搭建svn服务以及迁移方法
- ffmpeg与ffserver配合使用搭建流媒体服务
- ffmpeg+ffserver媒体服务搭建小记
- windows7无法访问windows2003server搭建的共享服务
- 用crtmpserver搭建开源rtmp直播服务
- 在Ubuntu 12.04 64bit上搭建Crtmpserver视频点播服务
- 使用LVS(Linux Virtual Server)在Linux上搭建负载均衡的集群服务
- 关于利用ffserver搭建RTSP服务的代码 Streaming with FFServer
- ffmpeg+ffserver媒体服务搭建小记
- ffmpeg+ffserver媒体服务搭建小记
- 用nodejs http-server搭建本地服务环境