hooks #5

Closed
gjohnson opened this Issue Mar 25, 2013 · 2 comments

Comments

Projects
None yet
3 participants
Contributor

gjohnson commented Mar 25, 2013

@visionmedia figured I would get some feedback before I add this, something you would pull in? My main use-case is using before hooks to clean up some validation mess in my methods and then leverage after hooks for logging, redis-counters, etc.

Option A:

before hooks

server.before(function(msg, next){
  // muck with msg if you want
  next();
});

server.before('add', function(msg, next){
  // muck with msg if you want
  next()
});

after hooks

server.after(function(res){
  console.log('generic logging')
});

server.after('add', function(res){
  console.log('sum = %s', res)
});

Option B:

Reconfigure a few things to maintain a connect like function stack ala middleware.

server.use(before);
server.use(server.dispatch)
server.use(after);

function before(msg, next){

};

function after(msg, next){

}
Owner

tj commented Mar 25, 2013

+1 for option A

@gjohnson gjohnson referenced this issue Apr 3, 2013

Closed

hook api #6

Collaborator

bretcope commented May 7, 2014

Pull request was closed nine months ago, so I'm closing this issue as well. If someone wants to suggest this sort of functionality in the future, they can start a new issue.

@bretcope bretcope closed this May 7, 2014

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