Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added ability to add middleware classes #243

Merged
merged 4 commits into from
Aug 16, 2018
Merged

Conversation

josephmancuso
Copy link
Member

@josephmancuso josephmancuso commented Aug 16, 2018

This PR adds the ability to add middleware "groups" which are just lists of middleware.

Previously we were only able to use middleware like this:

ROUTE_MIDDLEWARE = {
    'auth': 'app.http.middleware.AuthMiddleware.AuthMiddleware',
}

Now we can add a list group:

ROUTE_MIDDLEWARE = {
    'auth': 'app.http.middleware.AuthMiddleware.AuthMiddleware',
    'is.owner': [
        'app.http.middleware.AuthMiddleware.AuthMiddleware',
        'app.http.middleware.OwnerMiddleware.OwnerMiddleware',
    ] 
}

This will run all middleware in the list.

I'll need to make a new fix for 2.1 since this won't work. 2.1 uses new Class based middleware:

from app.http.middleware import AuthMiddleware, OwnerMiddleware

ROUTE_MIDDLEWARE = {
    'auth': AuthMiddleware,
    'is.owner': [
        AuthMiddleware,
        OwnerMiddleware,
    ] 
}

@josephmancuso josephmancuso self-assigned this Aug 16, 2018
@josephmancuso josephmancuso added the next minor Issue scheduled for the next minor release label Aug 16, 2018
@coveralls
Copy link

coveralls commented Aug 16, 2018

Coverage Status

Coverage increased (+0.2%) to 91.873% when pulling f4a49f7 on add-middleware-list into 698ac69 on master.

@josephmancuso josephmancuso merged commit 58db21a into master Aug 16, 2018
@josephmancuso josephmancuso deleted the add-middleware-list branch August 16, 2018 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next minor Issue scheduled for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants