Permalink
Browse files

Middleware doesn't get propagated to namespaced and custom routes

Before, this didn't work.

map.namespace 'api', {middleware: mw.requireAdmin}, (api) ->
    api.resources 'users'
    api.resources 'places', (place) ->
      place.get 'children', 'places#showChildren'
      place.collection (places) ->
        places.get 'find', 'places#findByName'

Middleware from this needs to be added to params
  • Loading branch information...
1 parent 807d51d commit 0e9ad2a4d9cbe8fb148ed67c7e73e4d12cab405a @tomaash tomaash committed Jun 6, 2013
Showing with 12 additions and 0 deletions.
  1. +12 −0 lib/railway_routes.js
View
@@ -126,6 +126,12 @@ Map.prototype.root = function (handler, middleware, options) {
handler = null;
}
+ if (!middleware) {
+ middleware = []
+ }
+
+ middleware = middleware.concat(this.middlewareStack)
+
if (!controller && this.latestResource) {
controller = this.latestResource;
} else if (!controller) {
@@ -301,6 +307,12 @@ Map.prototype.resources = function (name, params, actions) {
actions = params;
params = {};
}
+
+ if (!params.middleware) {
+ params.middleware = []
+ }
+
+ params.middleware = params.middleware.concat(this.middlewareStack)
params.appendFormat = ('appendFormat' in params) ? params.appendFormat : true;

0 comments on commit 0e9ad2a

Please sign in to comment.