File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727from starlette .responses import Response
2828from starlette .routing import Mount , Route , WebSocketRoute
2929from starlette .types import Receive , Scope , Send
30+ from starlette .websockets import WebSocket
3031
3132from .types_ .core import RouteCoro
3233
@@ -95,7 +96,13 @@ def __init__(self, **kwargs: Unpack[RouteOptions]) -> None:
9596 self ._include_in_schema : bool = kwargs ["include_in_schema" ]
9697
9798 async def __call__ (self , scope : Scope , receive : Receive , send : Send ) -> Any :
98- request : Request = Request (scope , receive , send )
99+ request : Request | WebSocket
100+
101+ if self ._is_websocket :
102+ request = WebSocket (scope , receive , send )
103+ else :
104+ request = Request (scope , receive , send )
105+
99106 response : Response | None = await self ._coro (self ._view , request )
100107
101108 if not response :
You can’t perform that action at this time.
0 commit comments