docs/examples/middleware/middleware_protocol_migration_old.py
raw| 1 | from litestar.middleware import MiddlewareProtocol |
| 2 | from litestar.types import ASGIApp, Receive, Scope, Send |
| 3 | |
| 4 | |
| 5 | class MyMiddleware(MiddlewareProtocol): |
| 6 | def __init__(self, app: ASGIApp) -> None: |
| 7 | self.app = app |
| 8 | |
| 9 | async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: |
| 10 | # do stuff |
| 11 | await self.app(scope, receive, send) |