Skip to content

Commit 4a4607d

Browse files
committed
support websockets
1 parent 0fb3381 commit 4a4607d

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

lib/caronte/index.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,24 @@ function createRightProxy(type) {
3030
return passes[pass];
3131
});
3232

33-
return function(req, res, opts) {
33+
return function(req, res /*, [head], [opts] */) {
3434
var self = this,
35-
ev = 'caronte:' + type + ':';
35+
args = [].slice.call(arguments),
36+
cntr = args.length - 1,
37+
ev = 'caronte:' + type + ':',
38+
head;
3639

37-
if(typeof opts !== 'undefined') { options = opts; }
40+
if(
41+
!(args[cntr] instanceof Buffer) &&
42+
args[cntr] !== res
43+
) {
44+
options = opts;
45+
cntr--;
46+
}
47+
48+
if(args[cntr] instanceof Buffer) {
49+
head = args[cntr];
50+
}
3851

3952
options.ee.emit(ev + 'begin', req, res);
4053

lib/caronte/passes/ws.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
var WebsocketStream = require('../streams/websocket'),
2+
passes = exports;
3+
14
/*!
25
* Array of passes.
36
*

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"dox" : "*",
1616
"coveralls" : "*",
1717
"mocha-lcov-reporter": "*",
18-
"blanket" : "*"
18+
"blanket" : "*",
19+
"ws" : "*"
1920
},
2021
"scripts" : {
2122
"blanket" : { "pattern": "caronte/lib" },

0 commit comments

Comments
 (0)