refactoring

This commit is contained in:
Maxim Devaev
2022-04-11 16:34:07 +03:00
parent 6bd2b9c680
commit 80b5546d21
3 changed files with 25 additions and 21 deletions

View File

@@ -255,9 +255,12 @@ class HttpServer:
unix_path: str,
unix_rm: bool,
unix_mode: int,
heartbeat: float,
access_log_format: str,
) -> None:
self.__heartbeat = heartbeat # pylint: disable=attribute-defined-outside-init
if unix_rm and os.path.exists(unix_path):
os.remove(unix_path)
server_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
@@ -274,6 +277,15 @@ class HttpServer:
loop=asyncio.get_event_loop(),
)
# =====
async def _make_ws_response(self, request: Request) -> WebSocketResponse:
ws = WebSocketResponse(heartbeat=self.__heartbeat)
await ws.prepare(request)
return ws
# =====
async def _init_app(self, app: Application) -> None:
raise NotImplementedError
@@ -283,6 +295,8 @@ class HttpServer:
async def _on_cleanup(self, app: Application) -> None:
_ = app
# =====
async def __make_app(self) -> Application:
app = Application(middlewares=[normalize_path_middleware(
append_slash=False,