首页 > 其他 > 详细

moco-globalsettings

时间:2016-01-08 18:24:52      阅读:326      评论:0      收藏:0      [点我收藏+]

1.单个json文件

(1)目录配置

技术分享

(2)新建foo.json

在project文件夹中新建foo.json

[
    {
        "request" : {
            "uri" : "/foo"
        },
        "response" : {
            "text" : "foo"
        }
    }
]

(3)执行&访问

windows在命令行cmd中:
java -jar moco-runner-0.10.2-standalone.jar start -p 12306 -c project/foo.json
浏览器中访问:
http://localhost:12306/foo

2.Golbal-Settings
We could put all configurations in one single configuration files. But if we want stub many services in a single Moco instance, the configurations file would be huge.
In this case, we can use settings file to separate our configurations for different into different configugration files.
意思是,当一个moco实例要对外提供非常多的json文件时候,可以用include将所有json文件统一注册

(1)准备json文件

技术分享

bar.json
[ { "request" : { "uri" : "/foo" }, "response" : { "text" : "foo" } } ]
main.json
[ { "include" : "project/foo.json" }, { "include" : "
project/bar.json"
}
]
注意文件的路径,否则会抛找不到文件

(2)执行&访问

windows在命令行cmd中:
java -jar moco-runner-0.10.2-standalone.jar start -p 12306 -g project/main.json
浏览器中访问:
http://localhost:12306/foo
http://localhost:12306/bar

 


3.Context

context.json
[ { "context": "/foo", "include": "project/foo.json" }, { "context": "/bar", "include": "project/bar.json" } ]
windows在命令行cmd中:
java -jar moco-runner-0.10.2-standalone.jar start -p 12306 -g project/context.json
浏览器中访问:
http://localhost:12306/foo/foo
http://localhost:12306/bar/bar

 

moco-globalsettings

原文:http://www.cnblogs.com/lyt19871224/p/5113916.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!