umocker

1.1.3 • Public • Published

安装

  • install Node.js
  • $ npm install -g umocker

使用

  • $ umocker -h

支持功能

  • 修改接口返回参数:$ umocker -sr replace_response_data /path/to/api_config.json
  • 修改接口Response Code:$ umocker -sr replace_response_status_code /path/to/api_config.json
  • 修改接口host:$ umocker -sr reverse_proxy /path/to/api_config.json
  • 修改接口请求参数:$ umocker -sr replace_request_option /path/to/api_config.json
  • 限速(kb/s):$ umocker -st 10
  • 延迟response返回:$ umocker -sr pause_response_time /path/to/api_config.json
  • 抓取HTTPs请求:默认支持,电脑和手机需要配置证书
  • 多个接口同时配置,见示例中修改接口返回参数,扩充字典即可
  • 保存接口请求到文件: $ umocker -sf /path/to/file

示例

  • 配置文件/path/to/api_config.jsonhostnamepathname为必选参数。
  • 修改接口返回参数:
{
  "apis": [
    {
      "hostname": "api.douban.com",
      "pathname": "/v2/user/test",
      "name": "test"
    }
  ]
}
  • 修改接口Response Code:
{
  "apis": [
    {
      "hostname": "api.douban.com",
      "pathname": "/v2/user/test",
      "statusCode": "304"
    }
  ]
}
  • 修改接口host:
{
  "apis": [
    {
      "hostname": "api.douban.com",
      "pathname": "/v2/user/test",
      "host": "127.0.0.1"
    }
  ]
}
  • 修改接口请求参数:
{
  "apis": [
    {
      "hostname": "api.douban.com",
      "pathname": "/v2/user/test",
      "ver": "5.10.2"
    }
  ]
}
  • 延迟response返回ms():
{
  "apis": [
    {
      "hostname": "api.douban.com",
      "pathname": "/v2/user/test",
      "pauseTime": "1500"
    }
  ]
}

Readme

Keywords

none

Package Sidebar

Install

npm i umocker

Weekly Downloads

0

Version

1.1.3

License

ISC

Last publish

Collaborators

  • hannah_qing