Permalink
Browse files

Merge pull request #20 from tomaash/master

Namespace middleware fix
  • Loading branch information...
2 parents 0796be6 + 2e3955f commit 13254d3cbb8b496a144c623aa4978dfef38c7297 @1602 committed Jul 10, 2013
Showing with 17 additions and 1 deletion.
  1. +16 −0 lib/railway_routes.js
  2. +1 −1 test/routes.test.js
View
@@ -126,6 +126,14 @@ Map.prototype.root = function (handler, middleware, options) {
handler = null;
}
+ if (!middleware) {
+ middleware = []
+ }
+
+ if (middleware instanceof Array) {
+ middleware = middleware.concat(this.middlewareStack)
+ }
+
if (!controller && this.latestResource) {
controller = this.latestResource;
} else if (!controller) {
@@ -301,6 +309,14 @@ Map.prototype.resources = function (name, params, actions) {
actions = params;
params = {};
}
+
+ if (!params.middleware) {
+ params.middleware = []
+ }
+
+ if (params.middleware instanceof Array) {
+ params.middleware = params.middleware.concat(this.middlewareStack)
+ }
params.appendFormat = ('appendFormat' in params) ? params.appendFormat : true;
View
@@ -254,5 +254,5 @@ test('should clone object with prefix', function() {
var clone = map.clone('/prefix');
map.pathTo.testUrl().should.equal('/test/url');
map.pathTo.testUrl().should.equal('/test/url');
- clone.testUrl().should.equal('/prefix/test/url');
+ clone.testUrl().should.equal('prefix/test/url');
});

0 comments on commit 13254d3

Please sign in to comment.