Deprecated

This page is an archive of features that ahttp_client v1 used to document but has since dropped. If you’re upgrading from v1 and something you relied on went missing, it’s probably here. None of the code on this page is importable from the current package.

Multiple Hooking

Deprecated since version 2.0: Removed. There is no direct replacement.

multiple_hook used to let several functions hook the same before/after stage of a request:

 1class MetroAPI(AsyncSession):
 2    def __init__(self):
 3        super().__init__("https://api.yhs.kr", aiohttp.ClientSession)
 4
 5    @request("GET", "/metro/station")
 6    async def station_search_with_query(
 7            self,
 8            response: Response,
 9            name: Query | str
10    ) -> dict[str, Any]:
11        return response.json()
12
13    @multiple_hook(station_search_with_query.before_hook)
14    async def before_hook_1(self, obj, path):
15        # Set-up before request
16        return obj, path
17
18    @multiple_hook(station_search_with_query.before_hook)
19    async def before_hook_2(self, obj, path):
20        # Set-up before request
21        return obj, path

As of v2.0, RequestCore.before_hook/after_hook (see Pre Hooking / Post Hooking) each accept only a single function. If more than one action is needed at a stage, combine them inside that one hook function instead of stacking multiple_hook calls.

Pydantic Response Model

Deprecated since version 2.0: Removed. Replaced by Serialization.

ahttp_client.extension.pydantic_response_model(model) used to deserialize a JSON response into a pydantic.BaseModel subclass, taking the model type directly: @pydantic_response_model(Repository).

@deserialize from Serialization now fills that role, and does more: it also supports dataclasses and marshmallow models, and can be paired with @serialize for the request body:

from ahttp_client.serializer import deserialize

@get("/users/{user}/repos", directly_response=True)
@deserialize()
async def list_repositories(self, response: Response, user: Annotated[str, Path]) -> list[Repository]:
    raise AssertionError("direct deserialization skips the method body")