lib/middleware.js
function use(events, middleware)
{
  // if no middleware supplied assume it's single argument call
  if (!middleware)
  {
    middleware = events;
    events     = null;
  }

  // make it uniform
  events = normalizeEvents(events);

  // store middleware per event
  events.forEach(function(e)
  {
    // bind middleware to the current context
    (this._stack[e] = this._stack[e] || []).push(middleware.bind(this));

    // make mark in history
    this.logger.debug({message: 'Added middleware to the stack', event: e, middleware: middleware});
  }.bind(this));
}
function use(events, middleware)
{
  // if no middleware supplied assume it's single argument call
  if (!middleware)
  {
    middleware = events;
    events     = null;
  }

  // make it uniform
  events = normalizeEvents(events);

  // store middleware per event
  events.forEach(function(e)
  {
    // bind middleware to the current context
    (this._stack[e] = this._stack[e] || []).push(middleware.bind(this));

    // make mark in history
    this.logger.debug({message: 'Added middleware to the stack', event: e, middleware: middleware});
  }.bind(this));
}
function use ( events , middleware ) { // if no middleware supplied assume it's single argument call if ( ! middleware ) { middleware = events ; events = null ; } // make it uniform events = normalizeEvents ( events ) ; // store middleware per event events . forEach ( function ( e ) { // bind middleware to the current context ( this . _stack [ e ] = this . _stack [ e ] || [ ] ) . push ( middleware . bind ( this ) ) ; // make mark in history this . logger . debug ( { message : 'Added middleware to the stack' , event : e , middleware : middleware } ) ; } . bind ( this ) ) ; }
Adds provided middleware to the stack,
with optional list of events

@this  Fbbot#
@param {string|array} [events] - list of events to associate middleware with
@param {function} middleware - request/event handler
Adds provided middleware to the stack with optional list of events