DI Integration — Aquilia Documentation
Comprehensive guide and documentation for DI Integration in the Aquilia framework. View API reference, examples, and implementation patterns.
HTTP Client / Integration Aquilia Integration Using the HTTP client within Aquilia: dependency injection, config builders, and integration with other subsystems. Dependency Injection The AsyncHTTPClient integrates seamlessly with Aquilia's DI container: from aquilia import Controller, RequestCtx, Response from aquilia.http import AsyncHTTPClient class UsersController(Controller): prefix = "/users" def __init__(self, http: AsyncHTTPClient): self.http = http async def get_user_data(self, ctx: RequestCtx): response = await self.http.get("https://api.github.com/users/octocat") user_data = await response.json() return Response.json(user_data) Configuration via Workspace Configure HTTP clients in your workspace.py: from aquilia import Workspace, Integration from aquilia.http import HTTPClientConfig, TimeoutConfig, RetryConfig, PoolConfig workspace = Workspace( integrations=[ # Configure default HTTP client Integration.http_client( config=HTTPClientConfig( timeout=TimeoutConfig(total=30.0), pool=PoolConfig(max_connections=100), ), ), # Named HTTP client for specific API Integration.http_client( name="github_client", config=HTTPClientConfig( base_url="https://api.github.com", ), ), ], ) Provider Scopes HTTP clients can be registered with different DI scopes: Singleton (default) One client instance shared across the entire app lifecycle. This is highly recommended to benefit from connection pooling reuse. Request Scope Creates a new client instance per request. Use with caution as it destroys pooling efficiency. Error Handling )
Go to Homepage