diff --git a/lib/caronte.js b/lib/caronte.js index ed5e4253a..444e8fd25 100644 --- a/lib/caronte.js +++ b/lib/caronte.js @@ -51,6 +51,7 @@ proxy.createProxyServer = function createProxyServer(options) { options.ee = new events.EventEmitter2({ wildcard: true, delimiter: ':' }); return { + ee : options.ee, web : caronte.createWebProxy(options), ws : caronte.createWsProxy(options), listen : function listen(port) { @@ -63,9 +64,6 @@ proxy.createProxyServer = function createProxyServer(options) { server.listen(port); return server; - }, - emitter : function() { - return options.ee; } }; }; diff --git a/lib/caronte/index.js b/lib/caronte/index.js index 747a64bab..194676e8b 100644 --- a/lib/caronte/index.js +++ b/lib/caronte/index.js @@ -30,9 +30,12 @@ function createRightProxy(type) { return passes[pass]; }); - return function(req, res) { + return function(req, res, opts) { var self = this, ev = 'caronte:' + type + ':'; + + if(typeof opts !== 'undefined') { options = opts; } + options.ee.emit(ev + 'begin', req, res);