Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

hooks #5

Closed
gjohnson opened this Issue · 2 comments

3 participants

@gjohnson

@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){

}
@tj
Owner
tj commented

+1 for option A

@gjohnson gjohnson referenced this issue
Closed

hook api #6

@bretcope
Collaborator

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.