HTTP Extractors — Aquilia Documentation
Comprehensive guide and documentation for HTTP Extractors in the Aquilia framework. View API reference, examples, and implementation patterns.
Dependency Injection / Extractors HTTP Parameter Extractors Bind incoming HTTP metadata directly to your service parameters using the built-in Header, Query, and Body extractors. How Extractors Work When the RequestDAG resolves dependencies, it checks if any parameter is annotated with an extractor dataclass. If it is, the DAG intercepts the resolution and reads the value straight from the request: from typing import Annotated from aquilia.di import Header, Query, Dep from aquilia.controller import Controller, get async def search_telemetry( user_agent: Annotated[str, Header("User-Agent")], search_query: Annotated[str, Query("q", default="")] ): print(f"Tracking search: from ") return search_query class SearchController(Controller): # Recommended constructor injection for app-wide services def __init__(self, telemetry_client: TelemetryClient): self.telemetry = telemetry_client @get("/search") async def search_view( self, ctx, query: Annotated[str, Dep(search_telemetry)] ): await self.telemetry.track("search_run") return Header Extracts a specific HTTP header. Header name lookups are case-insensitive. from aquilia.di import Header @dataclass class Header: name: str # Header name (e.g. "Authorization") alias: Optional[str] = None # Alias key mapping required: bool = True # Raises ValidationFault if missing default: Any = None # Fallback value Query Extracts values from the query string (`?key=value`). from aquilia.di import Query @dataclass class Query: name: str # Key key (e.g. "page") default: Any = None # Default value required: bool = False # Raises ValidationFault if missing Body Directly injects the parsed request body. from aquilia.di import Body @dataclass class Body: media_type: str = "application/json" # Expected content-type Error Handling If an extractor is marked as required=True and the value doesn't exist in the HTTP request, Aquilia raises a ValidationFault. The Fault Engine intercepts this to return a structured HTTP 400 Bad Request to the client automatically. RequestDAG )
Go to Homepage