Browse files

fix http api

  • Loading branch information...
1 parent ee80c07 commit e2a8f8d60b57220caa198e9389c9b58a77198df7 @cloudhead committed Feb 10, 2011
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/journey.js
View
11 lib/journey.js
@@ -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;
@@ -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;
@@ -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,

0 comments on commit e2a8f8d

Please sign in to comment.