anyproxy 拦截发送请求

anyproxy接口流程

anyproxy rule模块

anyproxy 如何实现请求拦截

通过beforeSendRequest(requestDetail) 方法实现 ,requestDetail 参数构成:

 requestDetail 参数内容修改:

1、不做任何处理,返回null

2、修改请求协议,如下:

return {protocol: 'https'}

3、修改请求参数,如下:

var newOption= Object.assign({},requestDetail.requestOptions);

newOption.path = 'https://baidu.com'

return {requestOptions: newOption}

4、修改请求body

return {requestData : 'abcd'}

5、直接返回

return {

  response : {

    statusCode: 200,

           header: {'content-type': 'text/html'},

          body: 'this is test web'

    }

}

posted @ 2022-02-15 12:37  keena_jiao  阅读(218)  评论(0编辑  收藏  举报