Controller Engine — Aquilia Documentation
Comprehensive guide and documentation for Controller Engine in the Aquilia framework. View API reference, examples, and implementation patterns.
ControllerEngine aquilia.controller.engine — Route dispatch and execution The ControllerEngine orchestrates the route execution pipeline. It coordinates dependency injection, clearance evaluations, pipeline middleware flow execution, parameter binding, response contract casting/molding, and content negotiation. Class Definition param names _has_lifecycle_hooks: Dict[type, tuple] = # class -> (has_on_request, has_on_response) _simple_route_cache: Dict[int, bool] = # id(route) -> is_simple _clearance_cache: Dict[int, Any] = # id(route) -> merged Clearance or None def __init__( self, factory: ControllerFactory, enable_lifecycle: bool = True, fault_engine: Optional[Any] = None, effect_registry: Optional[Any] = None, clearance_engine: Optional[Any] = None, ): self.factory = factory self.enable_lifecycle = enable_lifecycle self.fault_engine = fault_engine self.effect_registry = effect_registry self.clearance_engine = clearance_engine`} language="python" /> execute() — The Main Entry Point The execute() method is the entrypoint called by ASGI adapters to run a matched route: Response:`} language="python" /> , , , , , , , ].map(( ) => ( ))} Parameter Binding & Contract Context The engine binds path parameters, query parameters, body parameters, and dependencies automatically. If a parameter is typed as a Contract subclass, the engine parses the body and validates it: During contract validation, the engine creates a ContractContext wrapping the request container. This context provides lazy resolution via LazyServiceProxy, allowing contracts to access DI services asynchronously: Sync and Async Handler Dispatch Since v1.4.0b5, the engine invokes each handler exactly once and awaits the returned value only when it is awaitable. This supports regular def handlers, native async def handlers, and synchronous decorators that return a coroutine. Do not call a handler once to inspect it and a second time to execute it. The engine no longer caches coroutine status by the temporary identity of bound method objects; this removes an intermittent CPython ID-reuse failure that could try to await a synchronous dictionary. ControllerFactory ControllerCompiler )
Go to Homepage