hiproxy
Version:
hiproxy - lightweight and powerful proxy tool for front-end developer based on Node.js.
34 lines (28 loc) • 724 B
JavaScript
/**
* @file Get proxy info
* @author zdying
*/
;
var getProxyInfo = require('../../rewrite/getProxyInfo');
module.exports = function (ctx, next) {
var req = ctx.req;
var res = ctx.res;
var hiproxy = this;
var hosts = hiproxy.hosts;
var rewrite = hiproxy.rewrite;
var body = [];
/**
* Emitted whenever the request end.
* @event ProxyServer#requestend
* @property {String} body request data
* @property {http.IncomingMessage} response request object
* @property {http.ServerResponse} response response object
*/
hiproxy.emit('requestend', {
body: body,
req: req,
res: res
});
ctx.proxy = getProxyInfo(req, hosts.getHost(), rewrite.getRule());
next();
};