Skip to content

Commit

Permalink
fix http api
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhead committed Feb 10, 2011
1 parent ee80c07 commit e2a8f8d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/journey.js
Expand Up @@ -205,6 +205,8 @@ journey.Router.prototype = {
constraints: [],

validateRoute: function (route, request, body, allowedMethods, cb) {
var that = this;

// Match the pattern with the url
var match = (function (pattern) {
var path = request.url.pathname;
Expand Down Expand Up @@ -244,6 +246,9 @@ journey.Router.prototype = {
if ((route.method.indexOf(request.method) !== -1) || !route.method) {
return cb(null, function (res, params) {
var args = [];

if (that.options.api === 'http') { args.push(request) }

args.push(res);
args.push.apply(args, match.slice(1).map(function (m) {
return /^\d+$/.test(m) ? parseInt(m) : m;
Expand Down Expand Up @@ -415,11 +420,7 @@ journey.Router.prototype = {
this.send = this.responder;

try {
if (that.options.api === 'http') {
destination.call(this, this.request, this, params || {});
} else {
destination.call(this, this, params || {});
}
destination.call(this, this, params || {});
} catch (err) {
this.respond({
body: { error: err.message || err,
Expand Down

0 comments on commit e2a8f8d

Please sign in to comment.