flask-uwsgi-websocket
flask-uwsgi-websocket copied to clipboard
Using request context with other decorators
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.