Restored simple RSGI support on KayaApp instances

This commit is contained in:
2026-07-15 22:19:16 +08:00
parent fa3ff32f66
commit 0d6ecce415
5 changed files with 22 additions and 28 deletions
+1 -1
View File
@@ -2,4 +2,4 @@
RSGI/Granian integration for the Kaya web framework.
Provides `RsgiContext`, `RsgiWebSocket`, and `RsgiApplication` to run Kaya apps on Granian's RSGI protocol.
Provides `RsgiContext`, `RsgiWebSocket` to run Kaya apps on Granian's RSGI protocol.
+1 -2
View File
@@ -1,9 +1,8 @@
from ._rsgi import RsgiApplication, RsgiContext, RsgiWebSocket
from ._rsgi import RsgiContext, RsgiWebSocket
from ._types import HTTPScope, WebSocketScope
__all__ = [
'RsgiApplication',
'RsgiContext',
'RsgiWebSocket',
'HTTPScope',
-23
View File
@@ -175,26 +175,3 @@ class RsgiWebSocket(WebSocket):
if message.kind == 'close':
raise StopAsyncIteration
return message
class RsgiApplication:
_app: AbstractKayaApp
def __init__(self, app: AbstractKayaApp) -> None:
self._app = app
def __rsgi_init__(self, loop: Any) -> None:
self._app.setup(loop)
def __rsgi_del__(self, loop: Any) -> None:
self._app.shutdown(loop)
async def __rsgi__(self,
scope: RSGIHTTPScope | RSGIWebsocketScope,
protocol: RSGIHTTPProtocol | RSGIWebsocketProtocol) -> None:
if scope.proto == 'ws':
ws = RsgiWebSocket(scope, protocol) # type: ignore[arg-type]
await self._app.handle_websocket(ws)
else:
ctx = RsgiContext(scope, protocol) # type: ignore[arg-type]
await self._app.handle_request(ctx)