mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-31 18:11:54 +08:00
refactoring
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user