Skip to content

A framework provide concise and aintuitive asynchronous HTTP request using annotation types and @decorator.

License

Notifications You must be signed in to change notification settings

gunyu1019/ahttp-client

Repository files navigation

ahttp-client

PyPI - Version PyPI - Downloads PyPI - License

An ahttp-client is Python package that provides concise and aintuitive asynchronous HTTP request using annotated type and @decorator.

Key Feautre

  • Defining a simple request method with decoration.
  • Managing HTTP Compoents using Annotated Types.
  • Providing Hooks before and after HTTP calls.

Getting Started

Implement a GithubService class extended with ahttp_client.Session. Then, create a list_repositories method using a request decorator.

An user argument define HTTP-component (Path) through annotation types.

class GithubService(Session):
    def __init__(self):
        super().__init__("https://api.github.com")

    @request("GET", "/users/{user}/repos")
    def list_repositories(
        user: Annotated[str, Path]
    ) -> dict[str, Any]:
        return 

Using the asynchronous context manager(async with), create a GithubService instance.

async with GithubService() as service:
    result = await service.list_repoisitories(user = "gunyu1019")
    print(result)

Client Session in GithubServices are terminated when leave the asynchronous context manager.

Documentaion

About

A framework provide concise and aintuitive asynchronous HTTP request using annotation types and @decorator.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages