Skip to content

Allow passing custom arguments to http client + Add better documentation on the subject #98

Open
@davidmezzetti

Description

@davidmezzetti

Hello,

I'm aware of the ability to set a custom http_client parameter but that is now requiring a bit more.

Looking at the code now:

        self._http_client = http_client or httpx.AsyncClient(
            transport=httpx.ASGITransport(app=self.fastapi, raise_app_exceptions=False),
            base_url=self._base_url,
            timeout=10.0,
        )

The latest version requires copying the base url and ASGITransport call. In my use case, I'd like to just override the timeout.

Could we add a new parameter such as client_args with a dictionary of options to overlay when creating the client. For example:

        self._http_client = http_client or httpx.AsyncClient(
          **{{
            transport=httpx.ASGITransport(app=self.fastapi, raise_app_exceptions=False),
            base_url=self._base_url,
            timeout=10.0,
          }, **client_args}
        )

This would have the benefit of allowing a user to override a single http client parameter without having to know what else to pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions