1919from ellar .core .templating import AppTemplating , Environment
2020from ellar .core .versioning import VERSIONING , BaseAPIVersioning
2121from ellar .di .injector import EllarInjector
22+ from ellar .di .providers import ModuleProvider
2223from ellar .logger import logger
2324from ellar .services .reflector import Reflector
2425from ellar .types import ASGIApp , T , TReceive , TScope , TSend
@@ -64,6 +65,8 @@ def __init__(
6465 else list (on_shutdown_event_handlers )
6566 )
6667
68+ self ._static_app : t .Optional [ASGIApp ] = None
69+
6770 self .state = State ()
6871 self .config .DEFAULT_LIFESPAN_HANDLER = (
6972 lifespan or self .config .DEFAULT_LIFESPAN_HANDLER
@@ -77,14 +80,11 @@ def __init__(
7780 lifespan = self .config .DEFAULT_LIFESPAN_HANDLER , # type: ignore
7881 )
7982 self .middleware_stack = self .build_middleware_stack ()
80-
81- self ._static_app : t .Optional [ASGIApp ] = None
82-
8383 self ._finalize_app_initialization ()
8484
8585 logger .info (f"APP SETTINGS: { self ._config .config_module } " )
8686
87- def statics_wrapper (self ) -> t .Callable :
87+ def _statics_wrapper (self ) -> t .Callable :
8888 async def _statics_func_wrapper (
8989 scope : TScope , receive : TReceive , send : TSend
9090 ) -> t .Any :
@@ -100,7 +100,7 @@ def _get_module_routes(self) -> t.List[BaseRoute]:
100100 _routes .append (
101101 Mount (
102102 str (self .config .STATIC_MOUNT_PATH ),
103- app = self .statics_wrapper (),
103+ app = self ._statics_wrapper (),
104104 name = "static" ,
105105 )
106106 )
@@ -137,7 +137,9 @@ def install_module(
137137 def get_guards (self ) -> t .List [t .Union [t .Type [GuardCanActivate ], GuardCanActivate ]]:
138138 return self ._global_guards
139139
140- def use_global_guards (self , * guards : "GuardCanActivate" ) -> None :
140+ def use_global_guards (
141+ self , * guards : t .Union ["GuardCanActivate" , t .Type ["GuardCanActivate" ]]
142+ ) -> None :
141143 self ._global_guards .extend (guards )
142144
143145 @property
@@ -204,12 +206,6 @@ def routes(self) -> t.List[BaseRoute]:
204206 def url_path_for (self , name : str , ** path_params : t .Any ) -> URLPath :
205207 return self .router .url_path_for (name , ** path_params )
206208
207- def mount (self , path : str , app : ASGIApp , name : str = None ) -> None :
208- self .router .mount (path , app = app , name = name )
209-
210- def host (self , host : str , app : ASGIApp , name : str = None ) -> None :
211- self .router .host (host , app = app , name = name )
212-
213209 def enable_versioning (
214210 self ,
215211 schema : VERSIONING ,
@@ -228,7 +224,10 @@ def _finalize_app_initialization(self) -> None:
228224 self .injector .container .register_instance (Reflector ())
229225 self .injector .container .register_instance (self .config , Config )
230226 self .injector .container .register_instance (self .jinja_environment , Environment )
231- self .injector .container .register_scoped (IExecutionContext , ExecutionContext )
227+ self .injector .container .register_scoped (
228+ IExecutionContext ,
229+ ModuleProvider (ExecutionContext , scope = {}, receive = None , send = None ),
230+ )
232231
233232 def add_exception_handler (
234233 self ,
0 commit comments