This commit is contained in:
yumoqing 2025-12-18 14:54:03 +08:00
parent 391287e353
commit 803c0f5112

View File

@ -22,6 +22,15 @@ from .filestorage import TmpFileRecord
from .loadplugins import load_plugins
from .real_ip import real_ip_middleware
startup_coros = []
cleanup_coros = []
def add_startup(coro):
startup_coros.append(coro)
def add_cleanup(coro):
cleanup_coros.append(coro)
class AHApp(web.Application):
def __init__(self, *args, **kw):
if not kw.get('client_max_size'):
@ -30,7 +39,9 @@ class AHApp(web.Application):
super().__init__(*args, **kw)
self.user_data = DictObject()
self.middlewares.insert(0, real_ip_middleware())
[ self.on_startup.append(c) for c in startup_coros ]
[ self.on_cleanup.append(c) for c in cleanup_coros ]
def set_data(self, k, v):
self.user_data[k] = v