From 8506aa532266c70b7a0fa1b779e685dc4840d8a1 Mon Sep 17 00:00:00 2001 From: maxime Date: Tue, 28 May 2024 02:19:34 +0200 Subject: [PATCH] [middleware] fix DomainMiddleware constructor for 0.35 --- halfapi/half_domain.py | 8 ++++---- halfapi/lib/domain_middleware.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/halfapi/half_domain.py b/halfapi/half_domain.py index 223f00d..f417d02 100644 --- a/halfapi/half_domain.py +++ b/halfapi/half_domain.py @@ -14,7 +14,6 @@ from starlette.applications import Starlette from starlette.middleware import Middleware from starlette.routing import Router, Route from starlette.schemas import SchemaGenerator -from .lib.responses import ORJSONResponse from .lib.acl import AclRoute @@ -84,15 +83,16 @@ class HalfDomain(Starlette): super().__init__( routes=self.gen_domain_routes(), middleware=[ - (DomainMiddleware, { - 'domain': { + Middleware( + DomainMiddleware, + domain={ 'name': self.name, 'id': self.id, 'version': self.version, 'halfapi_version': self.halfapi_version, 'config': self.config.get('domain', {}).get(self.name, {}).get('config', {}) } - }) + ) ] ) diff --git a/halfapi/lib/domain_middleware.py b/halfapi/lib/domain_middleware.py index f152dd6..cc3dd2f 100644 --- a/halfapi/lib/domain_middleware.py +++ b/halfapi/lib/domain_middleware.py @@ -17,7 +17,7 @@ class DomainMiddleware(BaseHTTPMiddleware): - acl """ - def __init__(self, app, domain): + def __init__(self, app, domain=None): """ app: HalfAPI instance """ logger.info('DomainMiddleware app:%s domain:%s', app, domain)