BlackSheep icon indicating copy to clipboard operation
BlackSheep copied to clipboard

Add ASGI BASED Middleware

Open bensarifathi opened this issue 2 years ago • 3 comments

Note: consider using Discussions to open a conversation about new features…

🚀 Feature Request am trying to use this library https://github.com/melvinkcx/fastapi-events which use an ASGI middleware and when i tryed to add this middleware to my app i got the following error: AttributeError: 'EventHandlerASGIMiddleware' object has no attribute '__qualname__'

Middleware call signature: async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:

bensarifathi avatar May 02 '23 18:05 bensarifathi

Hi @bensarifathi BlackSheep does not support currently middlewares that use the ASGI signature, because it has its own code API to work with requests and responses.

I don't like very much the idea of supporting that other way to describe middlewares, because then to follow the same logic blacksheep should also support ASGI way of defining request handlers. I already took this into consideration in the past.

I might reconsider but I have other things on my TODO list and started.

RobertoPrevato avatar May 05 '23 08:05 RobertoPrevato

Actually, I'm struggling right now to wrap a Blacksheep app into a few ASGI middlewares. It would be nice to have such a feature. ⚡

Klavionik avatar Dec 25 '23 22:12 Klavionik