metlo-labs / metlo

Metlo is an open-source API security platform.
https://metlo.com
MIT License
1.6k stars 91 forks source link

Python Django Ingestor Won't Work in Async mode #320

Closed dmdhrumilmistry closed 1 year ago

dmdhrumilmistry commented 1 year ago

According to the Django docs, current Django ingestor middleware won't work in asynchronous mode. Consider making changes as per Django doc for asynchronous support: https://docs.djangoproject.com/en/3.2/topics/http/middleware/#asynchronous-support

Example from doc:

import asyncio
from django.utils.decorators import sync_and_async_middleware

@sync_and_async_middleware
def simple_middleware(get_response):
    # One-time configuration and initialization goes here.
    if asyncio.iscoroutinefunction(get_response):
        async def middleware(request):
            # Do something here!
            response = await get_response(request)
            return response

    else:
        def middleware(request):
            # Do something here!
            response = get_response(request)
            return response

    return middleware
AHarmlessPyro commented 1 year ago

Thanks for the info @dmdhrumilmistry . We'll get a fix in ASAP 😃

AHarmlessPyro commented 1 year ago

Hey @dmdhrumilmistry , we've isolated the issue and fixed it. A new build (v 0.0.17) should be up momentarily