入门指南示例.md 1.6 KB

框架介绍

功能

  • 访问页面时,能够为页面添加自定义的HTTP请求头
  • 能够基于url匹配规则,为匹配到的url处理
  • 请求头配置获取方式包含:从文件读取、从storage读取、从websocket读取

推荐理由

  • 功能强大:可通过修改http请求头,实现灰度控制、流量控制、用户行为分析等

  • 可扩展性:通过插件的形式,可支持自定义运行规则

  • 跨平台支持:支持windows、mac、linux系统,支持chrome内核的浏览器

  • 调试方便:能够支持动态加载,即修改文件后可以立刻重新执行。

快速开始

step1:选择使用的传输配置方式

let config_read_type = 'websocket';//local,file,websocket,http

可选择使用本地缓存、文件、websocket、http等方式读取配置信息

step2:若使用websocket方式,需要配置websocket服务器地址

const wsUrl = 'ws://127.0.0.1:9002';

step3:通过websocket方式的交互过程如下

发送获取config请求

{"messageType":131073}

返回对应的config信息

{
   "debug_mode" : true,
   "format_version" : "1.1",
   "headers" : [
      {
         "action" : "add",
         "apply_on" : "req",
         "comment" : "test",
         "header_name" : "VTM_terminalno",
         "header_value" : "7555980277",
         "status" : "on",
         "url_contains" : ""
      }
   ],
   "target_page" : "",
   "use_url_contains" : false
}

step4:后续符合url过滤规则的页面,其请求都会附带请求头

alt text