GenweiWu / Blog

个人技术能力提升
MIT License
4 stars 0 forks source link

moco #82

Open GenweiWu opened 2 years ago

GenweiWu commented 2 years ago

mock server --moco

可以通过简单的配置json文件,就能实现mock服务器的效果

入门

1. 下载moco的jar包,并且启动

## 表示启动服务器,且启动端口为10081
java -jar moco-runner-1.3.0-standalone.jar http -p 10081 -g ./json/settings.json -s 9527

2. settings文件大概长这样

[

    {
        "include" : "./json/111.json"
    },
    {
        "include" : "./json/222.json"
    },
    {
        "include" : "./333.json"
    }
]

3. 对应111.json大概长这样

[
    {
        "description": "testService",
        "request": {
            "method": "get",
            "uri": "/v1/hello"
        },
        "response": {
            "json": {
                "code": 1,
                "msg": "get data success"
            },
            "headers": {
                "Content-Type": "application/json;charset=utf-8"
            }
        }
    }
]