需要java运行环境支持。下载jar包:moco-runner-<version>-standalone.jar
下面是参考:
配置
Moco的配置文件格式使用的是json。例如:
[
{
"response" :
{
"text" : "Hello, Moco"
}
}
]
请求响应配置
{
"request" :
{
"uri" : "/foo"
},
"response" :
{
"text" : "bar"
}
}
多文件配置
[
{
"include" : "foo.json"
},
{
"include" : "bar.json"
}
]
其中,foo.json和bar.json都是包含服务的配置文件。启动参数必须使用-g。
[ { "request": { "method": "post", "uri": "/tenants/login", "forms": { "email": "guiyun.wei@pekall.com", "password": "123" } }, "response": { "json": { "status": 0, "uid": 1 } } }, { "request": { "method": "post", "uri": "/tenants/login", "forms": { "email": "guiyun.wei@pekall.com", "password": "1234" } }, "response": { "json": { "status": 1 } } }, { "request": { "method": "post", "uri": "/tenants/logout", "forms": { "email": "guiyun.wei@pekall.com" } }, "response": { "json": { "status": 0 } } } ]