Permalink
Browse files

Introduced a bug while refactoring. Mapped redirects were broken.

  • Loading branch information...
1 parent 8b48aa4 commit 3e234f56b1a0692dfd42555174b51406e075fd50 @kishorenc committed Dec 23, 2011
Showing with 18 additions and 10 deletions.
  1. +17 −9 lib/road.js
  2. +1 −1 package.json
View
26 lib/road.js
@@ -2,7 +2,7 @@ var fs = require('fs');
var config = {};
-exports.version = '0.2.2';
+exports.version = '0.2.3';
this.configure = function (viewExtension, routes, useLayout, callback) {
config.viewExtension = viewExtension;
@@ -21,21 +21,29 @@ this.router = function (app) {
path = route[2],
controllerName = route[3],
actionName = route[4];
- app[method](path, function (req, res, next) {
- callController(controllerName, actionName, req, res, next)
- });
+ app[method](path, mappedResponse(controllerName, actionName));
} else {
var method = route[0],
path = route[1];
- app[method](path, function (req, res, next) {
- var controller = req.params.controller || "index";
- var action = req.params.action || "index";
- callController(controller, action, req, res, next);
- });
+ app[method](path, directResponse());
}
}
};
+function mappedResponse(controllerName, actionName) {
+ return function(req, res, next) {
+ callController(controllerName, actionName, req, res, next);
+ }
+}
+
+function directResponse() {
+ return function(req, res, next) {
+ var controller = req.params.controller || "index";
+ var action = req.params.action || "index";
+ callController(controller, action, req, res, next);
+ }
+}
+
function callController(controllerName, functionName, req, res, next) {
try {
var controller = require(config.appRoot+'/controllers/' + controllerName + "Controller");
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "road",
- "version": "0.2.2",
+ "version": "0.2.3",
"description": "A route helper for express.",
"homepage": "https://github.com/kishorenc/road",
"author": "Kishore Nallan <kishore@kishorelive.com>",

0 comments on commit 3e234f5

Please sign in to comment.