Closed SamWarden closed 1 year ago
Current process_request and process_response methods don't allow to wrap a handler call using with or try-except blocks. It would be more convenient to have a middlewares as in popular frameworks which calls each other and the handler at the end
process_request
process_response
with
try-except
Docs
@middleware async def middleware(request, handler):
Docs Source code
class Middleware(BaseMiddleware): async def __call__( self, handler: Callable[[Message, Dict[str, Any]], Awaitable[Any]], event: Message, data: Dict[str, Any] ) -> Any:
@app.middleware("http") async def middleware(request: Request, call_next):
class Middleware: async def __call__(self, request, handler):
Hello @SamWarden, thank you for your contribution. Today I created a pull request related to this issue. What do you think about implementation?
Current
process_request
andprocess_response
methods don't allow to wrap a handler call usingwith
ortry-except
blocks. It would be more convenient to have a middlewares as in popular frameworks which calls each other and the handler at the endReferences
Aiohttp
Docs
Aiogram 3.x
Docs Source code
FastAPI
Docs
Blacksheep
Docs