handler.py 文件源码

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

项目:calm 作者: bagrat 项目源码 文件源码
def _parse_and_update_body(self, handler_def):
        """Parses the request body to JSON."""
        if self.request.body:
            try:
                json_body = json.loads(self.request.body.decode('utf-8'))
            except json.JSONDecodeError:
                raise BadRequestError(
                    "Malformed request body. JSON is expected."
                )

            new_body = json_body
            if handler_def.consumes:
                try:
                    new_body = handler_def.consumes.from_json(json_body)
                except ValidationError:
                    # TODO: log warning or error
                    raise BadRequestError("Bad data structure.")

            self.request.body = new_body
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号