Skip to content

Commit 9f2323d

Browse files
committed
add uvicorn to asgi middleware
1 parent 5acd6dc commit 9f2323d

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

aikido_zen/context/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
current_context = contextvars.ContextVar("current_context", default=None)
2222

2323
WSGI_SOURCES = ["django", "flask"]
24-
ASGI_SOURCES = ["quart", "django_async", "starlette", "hypercorn_asgi"]
24+
ASGI_SOURCES = ["quart", "django_async", "starlette", "hypercorn_asgi", "uvicorn"]
2525

2626

2727
def get_current_context():

aikido_zen/sources/servers/uvicorn.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
from aikido_zen.helpers.get_argument import get_argument
22
from aikido_zen.sinks import before, on_import, patch_function
33
from aikido_zen.helpers.logging import logger
4+
from aikido_zen.sources.functions.asgi_middleware import InternalASGIMiddleware
5+
46

57
@before
68
def _init(func, instance, args, kwargs):
79
config = get_argument(args, kwargs, 0, "config")
810
if not config.app:
911
return
10-
1112
logger.debug("Server detected as: Uvicorn, Wrapping ASGI app with Zen.")
13+
config.app = InternalASGIMiddleware(config.app, "uvicorn")
1214

1315
@on_import("uvicorn.server", "uvicorn")
1416
def patch(m):

0 commit comments

Comments
 (0)