Skip to content

Allow for "global" filters #123

Open
RaphiePS opened this Issue Dec 18, 2013 · 5 comments

3 participants

@RaphiePS

There should be a "nice" way to have something run before all actions. For example, say I'm using connect-flash. I'd want to pass flash messages into every page, so it gets rather repetitive to have this in every controller:

controller.before('*', function(next) {
  this.messages = this.req.flash('messages');
  this.errors = this.req.flash('errors');
  // etc
  next();
});

I suppose something like this could be put in the middleware initializer, but in my mind initializers should represent application setup, not logic.

If you agree, I'd be happy to submit a pull request!

@jaredhanson
Owner
@RaphiePS

Didn't know that existed! Inheritance sounds perfect. I just took a glance at controller.js and couldn't find anything related to inheritance, but perhaps I didn't look hard enough.

@jaredhanson
Owner
@redking
redking commented Dec 18, 2013

Do you plan on releasing a changelog or updated docs for the latest release? I wasn't aware that controller inheritance had been added!

@jaredhanson
Owner
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.