Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/director/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@ Router.prototype.runlist = function (fns) {
// with false, or evaluation will short circuit.
//
Router.prototype.invoke = function (fns, thisArg, callback) {
var isHttpServerCallback = false
if (thisArg.req && thisArg.res) isHttpServerCallback = true
var self = this;

if (this.async) {
Expand Down Expand Up @@ -431,7 +433,9 @@ Router.prototype.invoke = function (fns, thisArg, callback) {
return _every(fn, apply);
}
else if (typeof fn === 'function') {
return fn.apply(thisArg, fns.captures || []);
var args = fns.captures || []
if (isHttpServerCallback) args = [thisArg.req, thisArg.res].concat(args)
return fn.apply(thisArg, args);
}
else if (typeof fn === 'string' && self.resource) {
self.resource[fn].apply(thisArg, fns.captures || []);
Expand Down
2 changes: 1 addition & 1 deletion test/server/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports.createServer = function (router) {
};

exports.handlers = {
respondWithId: function (id) {
respondWithId: function (req, res, id) {
this.res.writeHead(200, { 'Content-Type': 'text/plain' })
this.res.end('hello from (' + id + ')');
},
Expand Down