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:
@@ -12,6 +12,11 @@ from typing import Optional
|
||||
import aiohttp
|
||||
import aiohttp.web
|
||||
|
||||
try:
|
||||
from aiohttp.web import AccessLogger # type: ignore
|
||||
except ImportError:
|
||||
from aiohttp.helpers import AccessLogger # type: ignore
|
||||
|
||||
from ...logging import get_logger
|
||||
|
||||
from ...validators import ValidatorError
|
||||
@@ -138,6 +143,21 @@ async def get_multipart_field(reader: aiohttp.MultipartReader, name: str) -> aio
|
||||
return field
|
||||
|
||||
|
||||
# =====
|
||||
_REQUEST_AUTH_INFO = "_kvd_auth_info"
|
||||
|
||||
|
||||
def _format_P(request: aiohttp.web.BaseRequest, *_, **__) -> str: # type: ignore # pylint: disable=invalid-name
|
||||
return (getattr(request, _REQUEST_AUTH_INFO, None) or "-")
|
||||
|
||||
|
||||
AccessLogger._format_P = staticmethod(_format_P) # type: ignore # pylint: disable=protected-access
|
||||
|
||||
|
||||
def set_request_auth_info(request: aiohttp.web.BaseRequest, info: str) -> None:
|
||||
setattr(request, _REQUEST_AUTH_INFO, info)
|
||||
|
||||
|
||||
# =====
|
||||
class HttpServer:
|
||||
def run(
|
||||
|
||||
Reference in New Issue
Block a user