authorized_sanic.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:sanic 作者: channelcat 项目源码 文件源码
def authorized():
    def decorator(f):
        @wraps(f)
        async def decorated_function(request, *args, **kwargs):
            # run some method that checks the request
            # for the client's authorization status
            is_authorized = check_request_for_authorization_status(request)

            if is_authorized:
                # the user is authorized.
                # run the handler method and return the response
                response = await f(request, *args, **kwargs)
                return response
            else:
                # the user is not authorized.
                return json({'status': 'not_authorized'}, 403)
        return decorated_function
    return decorator
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号