#794 - Scope app middleware to a list of paths#837
Merged
Conversation
bajtos
force-pushed
the
feature/scope-middleware-to-path
branch
from
November 19, 2014 11:11
c040c28 to
dbf4d12
Compare
Add a new argument to `app.middleware` allowing developers
to restrict the middleware to a list of paths or regular expresions.
Modify `app.middlewareFromConfig` to pass `config.paths` as the second
arg of `app.middleware`.
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);
// From config
app.middlewareFromConfig(
handlerFactory,
{
phase: 'initial',
paths: ['/scope', /^\/(a|b)/]
});
bajtos
force-pushed
the
feature/scope-middleware-to-path
branch
from
November 19, 2014 14:43
dbf4d12 to
2baa4b0
Compare
Member
|
👍 |
bajtos
added a commit
that referenced
this pull request
Nov 19, 2014
#794 - Scope app middleware to a list of paths
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a new argument to
app.middlewareallowing developersto restrict the middleware to a list of paths or regular expresions.
Modify
app.middlewareFromConfigto passconfig.pathsas the secondarg of
app.middleware.Examples:
Close #794
/to @raymondfeng @ritch please review