Ejemplo n.º 1
0
        async def inner(request) -> aiohttp.web.Response:
            request_data = await request.json()
            try:
                res_object = await f(request_data)
                if res_object is None:
                    res_object = {}
                if "success" not in res_object:
                    res_object["success"] = True
            except Exception as e:
                tb = traceback.format_exc()
                self.log.warning(f"Error while handling message: {tb}")
                if len(e.args) > 0:
                    res_object = {"success": False, "error": f"{e.args[0]}"}
                else:
                    res_object = {"success": False, "error": f"{e}"}

            return obj_to_response(res_object)
Ejemplo n.º 2
0
 async def inner(request) -> aiohttp.web.Response:
     request_data = await request.json()
     res_object = await f(request_data)
     if res_object is None:
         raise aiohttp.web.HTTPNotFound()
     return obj_to_response(res_object)