Middleware¶
Cullinan middleware participates in the unified Web Runtime pipeline.
Main exports¶
middlewareMiddlewareMiddlewareChainBodyDecoderMiddlewareget_middleware_registry()reset_middleware_registry()
Legacy registration helpers still exist, but new code should favor decorator-based or startup-time registration through the active runtime.
Guidance¶
- keep middleware thin and delegate business logic to injected services
- avoid storing request-scoped state on long-lived middleware instances
- let the gateway pipeline handle composition and ordering
Example¶
from cullinan.web.middleware import Middleware
class AuditMiddleware(Middleware):
async def process_request(self, request):
return None
For older middleware integrations, the application bootstrap can bridge legacy registrations into the gateway pipeline.