Updated middleware to not be aiohttp deprecated
@@ -539,8 +539,8 @@ class HttpTransport(Invoker):
logging.getLogger('aiohttp.access').setLevel(logging.WARNING)
- async def middleware(app: web.Application, handler: Callable) -> Callable:
- async def middleware_handler(request: web.Request) -> web.Response:
+ @web.middleware
+ async def middleware(request: web.Request, handler: Callable) -> Callable:
async def func() -> web.Response:
request_ip = RequestHandler.get_request_ip(request, context)
if request.headers.get('Authorization'):
@@ -615,12 +615,13 @@ class HttpTransport(Invoker):
'{0:.5f}s'.format(round(request_time, 5))
))
+ if isinstance(response, (web.HTTPException, web.HTTPInternalServerError)):
+ raise response
+
return response
return await asyncio.shield(func())
- return middleware_handler
-
app = web.Application(middlewares=[middleware], # type: ignore
client_max_size=(1024 ** 2) * 100) # type: web.Application
app._set_loop(None) # type: ignore
