strongloop/loopback — pull request #837 by bajtos (2014-11-19 11:10:23+00:00)
Title: Scope app middleware to a list of paths

Add a new argument to `app.defineMiddlewarePhases` allowing developers
to restrict the middleware to a list of paths or regular expresions.

Examples:

// A string path (interpreted via path-to-regexp)
app.middleware('auth', '/admin', ldapAuth);

// A regular expression
app.middleware('initial', /^\/~(admin|root)/, rejectWith404);

// A list of scopes
app.middleware('routes', ['/api', /^\/assets/.*\.json$'], foo);

Close #794

/to @raymondfeng @ritch please review