Skip to content

Modify http request/response in javascript config file easily.

Notifications You must be signed in to change notification settings

humanhuang/webproxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Modify http request/response in javascript config file easily.

NPM version node version npm download

Web UI, Web Page Performance Analyze.

=======

Console Info

Install

npm install -g webproxy

Quick Start

1、Normal start

$ webproxy start

2、Modify default LISTENING port

$ webproxy --port 9000 start

3、Use rule config file

$ webproxy start --rule rule.js

there are some sample rules at ./rules

rule.js

use this rule.js to wrap define header in every javascript file.

exports.request = function (req) {
      //req.hostname
      //req.path
      //req.method
      //req.headers

      req.headers.proxy = '*request inject new field by webproxy*';

      return req;
};

exports.response = function (req, res) {

      //req.location
      //req.hostname
      //req.path
      //req.method
      //req.headers

      //res.statusCode
      //res.headers
      //res.responseBuffer

      res.headers.proxy = '*wrap define header by webproxy*'

      if (/javascript/.test(res.headers['content-type'])) {
            res.responseBuffer = ';define(function(require, exports, module){' + res.responseBuffer + '});';
      }

      return res;
};

Use webproxy as a node module

var webproxy = require('webproxy')

webproxy.start({
            port: 9000,
            ruleModule: require("./path/ruleModule.js"),
            staticPort: 9001,
            websocketPort: 9002,
            useWebUI: true,
            printConsoleInfo: true,
      });

About

Modify http request/response in javascript config file easily.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages