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 pass variables to middleware #556

Merged
merged 2 commits into from
Jan 30, 2019

Conversation

josephmancuso
Copy link
Member

@josephmancuso josephmancuso commented Jan 29, 2019

This PR for 2.2 allows you to pass in variables from a route to a middleware by using the : as a separator.

For example you can have a middleware like:

class ThrottleMiddleware:

    def before(self, value1, value2):
        pass

So you are accepting 2 values in your middleware and then you can send values from your routes list:

Get().route('..').middleware('throttle:2000,100')

which will then pass those two values to your middleware:

class ThrottleMiddleware:

    def before(self, value1, value2):
        value1 #== '2000'
        value2 #== '100'

Closes #556

@josephmancuso josephmancuso self-assigned this Jan 29, 2019
@coveralls
Copy link

coveralls commented Jan 29, 2019

Coverage Status

Coverage increased (+0.01%) to 89.844% when pulling f12df43 on add-passing-of-middleware into 89b98ef on develop.

@josephmancuso josephmancuso merged commit 0e511b0 into develop Jan 30, 2019
@josephmancuso josephmancuso deleted the add-passing-of-middleware branch April 1, 2019 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants