Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Introduced a bug while refactoring. Mapped redirects were broken.

  • Loading branch information...
commit 3e234f56b1a0692dfd42555174b51406e075fd50 1 parent 8b48aa4
Kishore Nallan authored

Showing 2 changed files with 18 additions and 10 deletions. Show diff stats Hide diff stats

  1. +17 9 lib/road.js
  2. +1 1  package.json
26 lib/road.js
@@ -2,7 +2,7 @@ var fs = require('fs');
2 2
3 3 var config = {};
4 4
5   -exports.version = '0.2.2';
  5 +exports.version = '0.2.3';
6 6
7 7 this.configure = function (viewExtension, routes, useLayout, callback) {
8 8 config.viewExtension = viewExtension;
@@ -21,21 +21,29 @@ this.router = function (app) {
21 21 path = route[2],
22 22 controllerName = route[3],
23 23 actionName = route[4];
24   - app[method](path, function (req, res, next) {
25   - callController(controllerName, actionName, req, res, next)
26   - });
  24 + app[method](path, mappedResponse(controllerName, actionName));
27 25 } else {
28 26 var method = route[0],
29 27 path = route[1];
30   - app[method](path, function (req, res, next) {
31   - var controller = req.params.controller || "index";
32   - var action = req.params.action || "index";
33   - callController(controller, action, req, res, next);
34   - });
  28 + app[method](path, directResponse());
35 29 }
36 30 }
37 31 };
38 32
  33 +function mappedResponse(controllerName, actionName) {
  34 + return function(req, res, next) {
  35 + callController(controllerName, actionName, req, res, next);
  36 + }
  37 +}
  38 +
  39 +function directResponse() {
  40 + return function(req, res, next) {
  41 + var controller = req.params.controller || "index";
  42 + var action = req.params.action || "index";
  43 + callController(controller, action, req, res, next);
  44 + }
  45 +}
  46 +
39 47 function callController(controllerName, functionName, req, res, next) {
40 48 try {
41 49 var controller = require(config.appRoot+'/controllers/' + controllerName + "Controller");
2  package.json
... ... @@ -1,6 +1,6 @@
1 1 {
2 2 "name": "road",
3   - "version": "0.2.2",
  3 + "version": "0.2.3",
4 4 "description": "A route helper for express.",
5 5 "homepage": "https://github.com/kishorenc/road",
6 6 "author": "Kishore Nallan <kishore@kishorelive.com>",

0 comments on commit 3e234f5

Please sign in to comment.
Something went wrong with that request. Please try again.