一 whistle安装(mac)
1 安装node.js
whistle是基于node实现的,node.js官网:http://nodejs.cn/
下载并按照提示安装
2 whistle安装
1) 终端使用npm命令安装whistle
$ npm install -g whistle
2) 终端启动whistle
aaadeMacBook-Pro:~ root# w2 start --init
[i] whistle@2.9.22 started
[i] 1. use your device to visit the following URL list, gets the IP of the URL you can access:
http://127.0.0.1:8899/
http://172.20.20.131:8899/
http://192.168.72.115:8899/
Note: If all the above URLs are unable to access, check the firewall settings
For help see https://github.com/avwo/whistle
[i] 2. set the HTTP proxy on your device with the above IP & PORT(8899)
[i] 3. use Chrome to visit http://local.whistlejs.com/ to get started
Setting global proxy (127.0.0.1:8899) successful.
security: SecKeychainCopyDefault: A default keychain could not be found.
添加「--init」会初始化mac的全局代理设置,关闭whislte后需要把下图的两个☑️去掉才能正常联网
mac网络偏好设置
3) whistle其他操作
关闭whistle
$ w2 stop
重启whistle
$ w2 restart
whistle帮助
$ w2 help
3 打开whistle后台管理页面
在浏览器输入127.1:8899进入whistle后台管理页面
二 https证书安装
1 证书下载
点击whistle页面菜单中的HTTPS,点击二维码,即可下载证书。
2 证书安装
https://jingyan.baidu.com/article/5225f26ba6dbfce6fb090856.html
三 修改接口返回值
需要先找到需要修改返回值的接口
1 获取返回结果模板
打开浏览器访问页面,在控制台中找到需要修改返回值的接口,copy该接口的返回值
2 设置返回结果
打开whistle管理页面,在value中新建一个json文件,将复制的内容粘贴到文件中,修改参数为自己需要的返回结果
修改后,要点击「save」才会保存生效
3 在rules中设置规则
进入Rules-->default中设置规则,内容格式:
#该接口请求的URL file://{values中存放该接口返回的文件名+文件后缀}
http://127.0.0.1:8080/test file://{list.json}
点击「save」即可生效
4 重新载入页面,查看接口返回结果
参考:
//www.greatytc.com/p/17c48959be44
https://www.cnblogs.com/lv-lxz/p/16030338.html
https://jingyan.baidu.com/article/5225f26ba6dbfce6fb090856.html
https://www.cnblogs.com/lv-lxz/p/16030338.html