Mock Server
生活随笔
收集整理的这篇文章主要介绍了
Mock Server
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
下载地址:https://repo1.maven.org/maven2/com/github/dreamhead/moco-runner/
此处使用standalone的方式,不使用api用法
启动方式(单独配置文件启动):java -jar (jar包位置) (协议) -p (端口) -c 配置文件地址
1 全局配置文件
[{"context":"/path1", "include":"startup.json"},{"context":"/path2", "include":"startup2.json"} ]这儿的启动方式有变化, 启动方式(全局配置文件启动):java -jar (jar包位置) (协议) -p (端口) -g 配置文件地址,访问要加上context的utl,如访问startup1.json中的访问方法,
访问路径为:http://localhost:8888/path1/demo/noparam
以下是一些常见的方法
config.json
[{"context":"/path1", "include":"startup.json"},{"context":"/path2", "include":"startup2.json"} ]startup.json
[{"description": "这是一个get请求","request": {"uri": "/demo","method": "get","queries": {"name": "lww","age": "34"}},"response": {"text": "返回的方式为文本","headers":{"Content-Type":"text/html;charset=gbk"}}},{"description": "这是一个不带有请求参数的get请求","request": {"uri": "/demo/noparam","method": "get"},"response": {"text": "这是不带有请求参数的get请求","headers": {"Content-Type":"text/html;charset=gbk"}}},{"description": "这是一个post的请求","request": {"uri": "/demo/postNoParam","method": "post"},"response": {"text": "这是一个post请求,不带有参数","headers": {"Content-Type":"text/html;charset=gbk"}}},{"description": "这是一个带有的参数的post请求","request": {"uri": "/demo/postwithparam","method": "post","forms": {"name": "lww","age": "45"}},"response": {"text": "这是一个post请求,并且带有参数","headers": {"Content-Type":"text/html;charset=gbk"}}},{"description": "这是一个get请求,带有cookie信息","request": {"uri": "/demo/withCookie","method": "get","cookies": {"hello": "lww"}},"response": {"headers": {"Content-Type":"text/html;charset=gbk"},"text": "这是一个带有cookie信息的get请求"}},{"description": "这是一个带有cookie信息的post请求","request": {"uri": "/demo/postwithcokie","method": "post","cookies": {"hello": "lww"},"json": {"name": "lww","age": "45"}},"response": {"text": "这是一个带有cookie信息的post请求","headers": {"Content-Type":"text/html;charset=gbk"}}},{"description": "这是一个带有返回状态码的请求","request": {"method": "get","uri": "/demo/withstatus"},"response": {"json": {"lww": "33333","age": "45"},"status": "200","headers": {"Content-Type":"text/html;charset=gbk"}}},{"description": "带有headers信息的请求,post与get一致","request": {"uri": "/demo/withheaders","method": "get","headers": {"content-type": "application/json"}},"response": {"text": "带有headers的请求"}},{"description": "重定向","request": {"uri": "/demo/cdx"},"redirectTo": "/demo/tocdx"},{"description": "重定向到这个","request": {"uri": "/demo/tocdx"},"response": {"text": "到这儿","headers": {"Content-Type":"text/html;charset=gbk"}}},{"description": "上传文件","request": {"uri": "/demo/file"},"response":{"file": "C:\\Users\\lwf\\Desktop\\test-output\\report.html"}}]startup2.json
[{"description": "这是delete请求","request": {"method": "delete","uri": "/demo/del"},"response": {"status": "200"}},{"description": "这是一个put方法","request": {"uri": "/demo/put","method": "put"},"response": {"status": "200"}},{"description": "xml","request": {"uri": "/demo/xml","text": {"xml": "<request><parameters><id>1</id></parameters></request>"}},"response": {"status": "200"}} ]更多查看:https://github.com/dreamhead/moco/blob/master/moco-doc/apis.md
以上是我暂时能想到的常用的请求
网上看教程moco是支持热部署的, 但是不知道是因为我下载的版本太低还是怎么回事并不能进行热部署
转载于:https://www.cnblogs.com/sailfan/p/10427939.html
《新程序员》:云原生和全面数字化实践50位技术专家共同创作,文字、视频、音频交互阅读总结
以上是生活随笔为你收集整理的Mock Server的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 最短路径问题-Dijkstra算法的py
- 下一篇: java常用的几种线程池