modern-di-fastapi 2.3.0__py3-none-any.whl → 2.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- modern_di_fastapi/__init__.py +10 -1
- modern_di_fastapi/main.py +3 -3
- {modern_di_fastapi-2.3.0.dist-info → modern_di_fastapi-2.5.0.dist-info}/METADATA +1 -1
- modern_di_fastapi-2.5.0.dist-info/RECORD +6 -0
- modern_di_fastapi-2.3.0.dist-info/RECORD +0 -6
- {modern_di_fastapi-2.3.0.dist-info → modern_di_fastapi-2.5.0.dist-info}/WHEEL +0 -0
modern_di_fastapi/__init__.py
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
from modern_di_fastapi.main import
|
|
1
|
+
from modern_di_fastapi.main import (
|
|
2
|
+
FromDI,
|
|
3
|
+
build_di_container,
|
|
4
|
+
fastapi_request_provider,
|
|
5
|
+
fastapi_websocket_provider,
|
|
6
|
+
fetch_di_container,
|
|
7
|
+
setup_di,
|
|
8
|
+
)
|
|
2
9
|
|
|
3
10
|
|
|
4
11
|
__all__ = [
|
|
5
12
|
"FromDI",
|
|
6
13
|
"build_di_container",
|
|
14
|
+
"fastapi_request_provider",
|
|
15
|
+
"fastapi_websocket_provider",
|
|
7
16
|
"fetch_di_container",
|
|
8
17
|
"setup_di",
|
|
9
18
|
]
|
modern_di_fastapi/main.py
CHANGED
|
@@ -11,8 +11,8 @@ from starlette.requests import HTTPConnection
|
|
|
11
11
|
T_co = typing.TypeVar("T_co", covariant=True)
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
fastapi_request_provider = providers.ContextProvider(scope=Scope.REQUEST, context_type=fastapi.Request)
|
|
15
|
+
fastapi_websocket_provider = providers.ContextProvider(scope=Scope.SESSION, context_type=fastapi.WebSocket)
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
def fetch_di_container(app_: fastapi.FastAPI) -> Container:
|
|
@@ -30,7 +30,7 @@ async def _lifespan_manager(app_: fastapi.FastAPI) -> typing.AsyncIterator[None]
|
|
|
30
30
|
|
|
31
31
|
def setup_di(app: fastapi.FastAPI, container: Container) -> Container:
|
|
32
32
|
app.state.di_container = container
|
|
33
|
-
container.providers_registry.add_providers(
|
|
33
|
+
container.providers_registry.add_providers(fastapi_request_provider, fastapi_websocket_provider)
|
|
34
34
|
old_lifespan_manager = app.router.lifespan_context
|
|
35
35
|
app.router.lifespan_context = _merge_lifespan_context(
|
|
36
36
|
old_lifespan_manager,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
modern_di_fastapi/__init__.py,sha256=0L62654ViTpIrOErhVebdlxH6Bk0mcQovnM_oMtpUzQ,339
|
|
2
|
+
modern_di_fastapi/main.py,sha256=TWaNKFq4wBEJ7DjoLeZfzfNQRLQbbwAzXQFFB-SnRoo,2587
|
|
3
|
+
modern_di_fastapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
modern_di_fastapi-2.5.0.dist-info/METADATA,sha256=umTZ8ZG7J5cS3RKTMyTyCSTCqZP72y3Jzmtf5oJDyjs,980
|
|
5
|
+
modern_di_fastapi-2.5.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
6
|
+
modern_di_fastapi-2.5.0.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
modern_di_fastapi/__init__.py,sha256=t4ox50Pc4k7bDNprfg3_ujqj4dwidTTuzV9WRNH-EOs,190
|
|
2
|
-
modern_di_fastapi/main.py,sha256=DVIZiLp-AOXKEIVNPLVWzOSZSAgSOGSF9i6iUxotCko,2585
|
|
3
|
-
modern_di_fastapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
modern_di_fastapi-2.3.0.dist-info/METADATA,sha256=JGU0_60dTdzX79N69yWuk2sp5i9Dltx799LqTwHqYc8,980
|
|
5
|
-
modern_di_fastapi-2.3.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
6
|
-
modern_di_fastapi-2.3.0.dist-info/RECORD,,
|
|
File without changes
|