Skip to content

Commit

Permalink
Fixed gotcha invoking app.param() callbacks once per route middleware.
Browse files Browse the repository at this point in the history
…Closes expressjs#638
  • Loading branch information
tj committed Apr 22, 2011
1 parent f5c4e9d commit 5688ea6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
23 changes: 3 additions & 20 deletions lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ Server.prototype.configure = function(env, fn){
// Generate routing methods

function generateMethod(method){
Server.prototype[method] = function(path, fn){
Server.prototype[method] = function(path){
var self = this;

// Lookup
Expand All @@ -461,27 +461,10 @@ function generateMethod(method){
}

// Ensure router is mounted
if (!this.__usedRouter) {
this.use(this.router);
}

// Route specific middleware support
if (arguments.length > 2) {
var args = Array.prototype.slice.call(arguments, 1);
fn = args.pop();
(function stack(middleware){
middleware.forEach(function(fn){
if (Array.isArray(fn)) {
stack(fn);
} else {
self[method](path, fn);
}
});
})(args);
}
if (!this.__usedRouter) this.use(this.router);

// Generate the route
this.routes[method](path, fn);
this.routes[method].apply(this, arguments);
return this;
};
return arguments.callee;
Expand Down
2 changes: 1 addition & 1 deletion support/connect
Submodule connect updated 2 files
+3 −1 lib/middleware/router.js
+21 −0 lib/utils.js

0 comments on commit 5688ea6

Please sign in to comment.