I have a small API written in flask. I am authenticating users with JWT token sent in headers. Now what I do is: my_func(): if auth(request.headers): # do sth else: return jsonify("msg": "Unautorized"), 401 That works for me, but... Is that nice? My idea was to use wrapper, to have something like @check_auth(request.headers): my_func(): # do sth but of course request is out of scope and it will not work this way. Any suggestions on how to make it simple but elegant? Or maybe I'm just trying to overengeneer it and should leave it like it is? Continue reading...