Controller Router — Aquilia Documentation
Comprehensive guide and documentation for Controller Router in the Aquilia framework. View API reference, examples, and implementation patterns.
ControllerRouter aquilia.controller.router — Two-tier URL matching engine The ControllerRouter matches incoming requests to compiled routes. It employs a two-tier matching strategy for maximum request throughput. Two-Tier Architecture Tier 1: Static Routes Uses a direct dictionary key lookup offering O(1) matching performance. Routes without parameters (e.g. GET /health) bypass regular expressions entirely. Tier 2: Dynamic Routes Uses compiled regex matching for routes with path chevrons (e.g. GET /users/«id:int»). Specificity sorting guarantees the correct route takes precedence. Class Definition None: """Clear all route indices and release native engine resources (v1.4.0b3).""" self.compiled_controllers.clear() self.routes_by_method.clear() self.matcher = PatternMatcher() self._static_routes.clear() self._dynamic_routes.clear() self._tries.clear() self._name_index.clear() self._native_methods.clear() self._native_routes.clear() self._native = None # Explicitly releases C++ extension reference self._initialized = False`} language="python" /> Native Engine Resource Teardown (v1.4.0b3) When running with native C++ acceleration enabled (aquilia._core.Router), router.clear() releases native handles. AquiliaServer.shutdown() and ASGIAdapter.shutdown() invoke clear() automatically during server teardown, ensuring nanobind extension objects are deallocated cleanly without warnings on process exit. ControllerRouteMatch Reverse URL Generation Generate paths dynamically using route names: ControllerCompiler OpenAPI Generation )
Go to Homepage