Possibility to add new transports at runtime #2947
-
When I write a reusable client, I don't necessarily know all URLs and the transports that will be needed at client creation time. |
Beta Was this translation helpful? Give feedback.
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? |
Beta Was this translation helpful? Give feedback.
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.