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

Using request context with other decorators #65

Open
rosensama opened this issue Nov 24, 2017 · 0 comments
Open

Using request context with other decorators #65

rosensama opened this issue Nov 24, 2017 · 0 comments

Comments

@rosensama
Copy link
Contributor

rosensama commented Nov 24, 2017

Under your Advanced Usage in the README docs it mentions how to expose the request context in a websocket handler using:

with app.request_context(ws.environ):

Is there a recommended way to do this so that the request context is available to other decorators? Say I have a @login_required decorator that invokes a check for a cookie or header? Should I roll my own decorator that combines the two? Do I need to unroll the @login_required decorator to occur as inline code after I've exposed the request context?

@ws.route('sockets/chat/<string:channel_name>')
@login_required
def websocket_chat(socket, channel_name):

Where @login_required expects to find the request context.

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

No branches or pull requests

1 participant