Autoload callback with request (backward compatible) #23

merged 2 commits into from Jun 29, 2011


None yet
2 participants

Autoload will call with the request if the callback can accept additional args
Issue #22

@@ -58,14 +58,21 @@ Resource.prototype.load = function(fn){
this.loadFunction = fn;, function(req, res, next){
- fn(req.params[id], function(err, obj){
+ var callback = function(err, obj){

tj Jun 27, 2011


function callback(


pacovell Jun 27, 2011

NP -- for my benefit, can you explain if this is stylistic or functional?


tj Jun 29, 2011


just stylistic, though it gives the function a name so that it will display in stack traces, but also a locally defined function so it's functionally equivalent but preferred

+ };
+ // Maintain backward compatibility
+ if (fn.length === 2) {

tj Jun 27, 2011


2 == fn.length


tj commented Jun 27, 2011

other than that, looks good

tj added a commit that referenced this pull request Jun 29, 2011

Merge pull request #23 from donedotcom/master
Added request to autoload callback [donedotcom]

@tj tj merged commit 456df1b into expressjs:master Jun 29, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment