refactor(name): rename the middleware

This commit is contained in:
YuehuCao 2025-09-23 13:07:11 +08:00
parent e9e863053d
commit 98f2ce4871
3 changed files with 5 additions and 5 deletions

View File

@ -1,4 +1,4 @@
from .freeleaps_auth_middleware import FreeleapsAuthMiddleware from .freeleaps_auth_middleware import FreeleapsAuthMiddleware
from .tenant_DB_connection_middleware import TenantDBConnectionMiddleware from .tenant_DBConnection_middleware import TenantDBConnectionMiddleware
__all__ = ['FreeleapsAuthMiddleware', 'TenantDBConnectionMiddleware'] __all__ = ['FreeleapsAuthMiddleware', 'TenantDBConnectionMiddleware']

View File

@ -29,7 +29,7 @@ class TenantDBConnectionMiddleware:
try: try:
tenant_cache = request.app.state.tenant_cache tenant_cache = request.app.state.tenant_cache
main_db = request.app.state.main_db main_db = request.app.state.main_db
await self.module_logger.log_info(f"Retrieved app state - tenant_cache: {'' if tenant_cache is not None else ''}, main_db: {'' if main_db is not None else ''}") await self.module_logger.log_info(f"Retrieved app state - tenant_cache: {'success' if tenant_cache is not None else 'fail'}, main_db: {'success' if main_db is not None else 'fail'}")
except Exception as e: except Exception as e:
await self.module_logger.log_error(f"Failed to get app state: {str(e)}") await self.module_logger.log_error(f"Failed to get app state: {str(e)}")
response = JSONResponse( response = JSONResponse(
@ -47,7 +47,7 @@ class TenantDBConnectionMiddleware:
request.state.db = main_db_initialized request.state.db = main_db_initialized
request.state.product_id = None request.state.product_id = None
await self.module_logger.log_info(f"Successfully initialized main database with tenant models") await self.module_logger.log_info(f"Successfully initialized main database with tenant models")
return await self.app(scope, receive, send) return await self.app(scope, receive, send)
try: try:
@ -57,7 +57,7 @@ class TenantDBConnectionMiddleware:
request.state.db = tenant_db request.state.db = tenant_db
request.state.product_id = product_id request.state.product_id = product_id
await self.module_logger.log_info(f"Successfully retrieved cached tenant database with Beanie for product_id: {product_id}") await self.module_logger.log_info(f"Successfully retrieved cached tenant database with Beanie for product_id: {product_id}")
return await self.app(scope, receive, send) return await self.app(scope, receive, send)
except ValueError as e: except ValueError as e:

View File

@ -1,5 +1,5 @@
from webapi.middleware.freeleaps_auth_middleware import FreeleapsAuthMiddleware from webapi.middleware.freeleaps_auth_middleware import FreeleapsAuthMiddleware
from webapi.middleware.tenant_DB_connection_middleware import TenantDBConnectionMiddleware from webapi.middleware.tenant_DBConnection_middleware import TenantDBConnectionMiddleware
def register(app): def register(app):