blackbull.middleware.utils¶
blackbull.middleware.utils
¶
Middleware send adapters.
Native wrappers receive NativeResponse on HTTP paths; ASGI dictionaries are introduced only at compatibility boundaries, never raw Response objects.
as_middleware(target)
¶
Decorate a function or class with (conn, receive, send, call_next) middleware.
Normalize downstream HTTP sends to NativeResponse before the middleware's send wrapper. A first request parameter named scope opts into ASGI scope and event dictionaries at both edges, including WebSocket events. Omit the decorator to handle raw downstream send arguments.