Any reason call_next definition has been moved inside of __call__ in BaseHTTPMiddleware? #1538
-
|
Before anyio integration update we had some use-cases for this as it made it straigtforward to customize the request type a little bit by simply overriding the class CustomBaseHTTPMiddleware:
def __init__(self, app: ASGIApp, dispatch: DispatchFunction = None) -> None:
self.app = app
self.dispatch_func = self.dispatch if dispatch is None else dispatch
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
if scope["type"] != "http":
await self.app(scope, receive, send)
return
request = CustomRequest(scope, receive=receive)
response = await self.dispatch_func(request, self.call_next)
await response(scope, receive, send)since the anyio stuff Is there any particular reason for this change? I couldn't see it discussed anywhere in the pr for the anyio changes... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
I guess it is because we needed this line: |
Beta Was this translation helpful? Give feedback.
I guess it is because we needed this line:
https://github.com/encode/starlette/blob/813aa8d934b9cca4fb4b1c24fb50d97a1733e50e/starlette/middleware/base.py#L38