Skip to content

Commit

Permalink
Fixed route-specific middleware when using the same callback function…
Browse files Browse the repository at this point in the history
… several times
  • Loading branch information
tj committed May 3, 2011
1 parent 5f0a854 commit 5366772
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/router/index.js
Expand Up @@ -79,13 +79,12 @@ function router(fn, app){
middleware = utils.flatten(middleware);
}

fn.middleware = middleware;

if (!path) throw new Error(name + ' route requires a path');
if (!fn) throw new Error(name + ' route ' + path + ' requires a callback');

var options = { sensitive: app.enabled('case sensitive routes') };
var route = new Route(name, path, fn, options);
route.middleware = middleware;
localRoutes.push(route);
return self;
};
Expand Down Expand Up @@ -129,7 +128,7 @@ function router(fn, app){
// route middleware
i = 0;
(function nextMiddleware(err){
var fn = route.callback.middleware[i++];
var fn = route.middleware[i++];
if ('route' == err) {
pass(req._route_index + 1);
} else if (err) {
Expand Down

0 comments on commit 5366772

Please sign in to comment.