지원 종료 (Deprecated)

이 페이지는 ahttp_client v1에 있었지만 지금은 빠진 기능들을 모아둔 아카이브입니다. v1에서 넘어오는데 쓰던 기능이 안 보인다면 아마 여기 있을 겁니다. 이 페이지에 나오는 코드는 지금 패키지에서는 import할 수 없습니다.

다중 후킹 (Multiple Hooking)

버전 2.0부터 폐지됨: 제거되었습니다. 직접적인 대체 기능은 없습니다.

multiple_hook 은 하나의 요청, 같은 before/after 단계를 여러 함수가 나눠서 후킹할 수 있게 해주는 기능이었습니다:

 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

v2.0부터는 RequestCore.before_hook/after_hook (Hooking 기능 참고)이 각각 함수 하나씩만 받습니다. 한 단계에서 여러 동작이 필요하면 multiple_hook 을 여러 번 쌓는 대신, 훅 함수 하나에 그 동작들을 다 넣으면 됩니다.

Pydantic 응답 모델

버전 2.0부터 폐지됨: 제거되었습니다. 직렬화 (Serialization) 으로 대체되었습니다.

ahttp_client.extension.pydantic_response_model(model) 은 @pydantic_response_model(Repository) 처럼 모델 타입을 직접 넘기면 JSON 응답을 pydantic.BaseModel 서브클래스로 역직렬화해주는 기능이었습니다.

지금은 이 역할을 직렬화 (Serialization) 의 @deserialize 가 대신합니다. dataclasses 와 marshmallow 모델까지 추가로 지원하고, 요청 본문 쪽은 @serialize 와 짝지어 쓸 수도 있습니다:

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")