lib/utils/handler.js
function(api, handler) {

        if( 0 === arguments.length )
            throw new Error('utils.handler.register needs arguments');

        if( ! _.isObject(api) )
            throw new Error('utils.handler.register needs an espressojs API');

        if( ! (handler instanceof Handler) )
            throw new Error('utils.handler.register needs a Handler');

        // Add it to _ids
        api._ids[ handler.getPattern().getExpression().toString() ] = handler;

        // Add it to _names if any
        var name = handler.getOption('name');

        if( _.isString(name) && ! _.isEmpty(name) )
            api._names[ name ] = handler;
    }
function(api, handler) {

        if( 0 === arguments.length )
            throw new Error('utils.handler.register needs arguments');

        if( ! _.isObject(api) )
            throw new Error('utils.handler.register needs an espressojs API');

        if( ! (handler instanceof Handler) )
            throw new Error('utils.handler.register needs a Handler');

        // Add it to _ids
        api._ids[ handler.getPattern().getExpression().toString() ] = handler;

        // Add it to _names if any
        var name = handler.getOption('name');

        if( _.isString(name) && ! _.isEmpty(name) )
            api._names[ name ] = handler;
    }
function ( api , handler ) { if ( 0 === arguments . length ) throw new Error ( 'utils.handler.register needs arguments' ) ; if ( ! _ . isObject ( api ) ) throw new Error ( 'utils.handler.register needs an espressojs API' ) ; if ( ! ( handler instanceof Handler ) ) throw new Error ( 'utils.handler.register needs a Handler' ) ; // Add it to _ids api . _ids [ handler . getPattern ( ) . getExpression ( ) . toString ( ) ] = handler ; // Add it to _names if any var name = handler . getOption ( 'name' ) ; if ( _ . isString ( name ) && ! _ . isEmpty ( name ) ) api . _names [ name ] = handler ; }
Registers a handler in the API
Registers a handler in the API