rest_router.py 文件源码

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

项目:ryu-lagopus-ext 作者: lagopus 项目源码 文件源码
def rest_command(func):
    def _rest_command(*args, **kwargs):
        try:
            msg = func(*args, **kwargs)
            return Response(content_type='application/json',
                            body=json.dumps(msg))

        except SyntaxError as e:
            status = 400
            details = e.msg
        except (ValueError, NameError) as e:
            status = 400
            details = e.message

        except NotFoundError as msg:
            status = 404
            details = str(msg)

        msg = {REST_RESULT: REST_NG,
               REST_DETAILS: details}
        return Response(status=status, body=json.dumps(msg))

    return _rest_command
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号