Controllers — Aquilia Documentation
Comprehensive guide and documentation for Controllers in the Aquilia framework. View API reference, examples, and implementation patterns.
Controllers aquilia.controller — Class-based request handlers Controllers are the primary request handling abstraction in Aquilia. Unlike function-based routing, Aquilia controllers are classes that support dependency injection, lifecycle hooks, pipeline execution, rate limiting, and content negotiation. Low-Level System Design The following diagram details the low-level execution flow when a request matches a controller endpoint: 1. ASGI Router Matches CompiledRoute Route Compiler Bakes metadata 2. Factory (DI) Instantiates instance 3. Pipeline Nodes Guards / Interceptors 4. Param Binding Contract casting/seal 5. Execute Handler Invokes method The Controller Base Class All controllers extend Controller . The base class provides: Response: products = await self.repo.list_all() return Response.json( )`} /> Class Attributes Attribute Type Default Description ))} Instantiation Modes per_request (default) A new controller instance is created for each incoming request. It supports the async context manager protocol (__aenter__ / __aexit__) for request-level resources (e.g. transactions). singleton A single instance is shared across all requests and lives for the entire server lifespan. Stateful startup and shutdown lifecycle hooks are executed in this mode only. In This Section → Route Decorators: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, WS → RequestCtx: The request context object and its properties → ControllerFactory: How controllers are instantiated with DI )
Go to Homepage