Possibility to add new transports at runtime #2947
Answered
by
karpetrosyan
noudin-ledger
asked this question in
Ideas
|
When I write a reusable client, I don't necessarily know all URLs and the transports that will be needed at client creation time. |
Answered by
karpetrosyan
Dec 18, 2023
Replies: 1 comment 5 replies
|
Hi! Nope, we don't support that. If you want a dynamic approach, then you could implement this using a custom transport... # Setup the initial transport config
dynamic_mountpoints = MyCustomTransport()
dynamic_mountpoints['https'] = httpx.HTTPTransport()
# Create the client
client = httpx.Client(transport=dynamic_mountpoints)
# Change the config dynamically
dynamic_mountpoints['https://www.example.com'] = ...What kind of use-case are you trying to support here? |
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's an example of a custom transport that handles such cases, allowing you to dynamically add a new mount point in the proper manner.