-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could we have .WithBaseUrl() option? #495
Comments
Hi @AndrewZenith Have you tried setting the base url of the request adapter of your client Let us know if you have any additional comments or questions. |
Hi, That's what I'm already doing. As I mentioned, you can't change it once the ApiClient is created, leading to the question of having a .WithBaseUrl() option. |
Thank you for the additional information. Have you considered having multiple request adapters and clients? and switching between them instead? If so, what are the challenges it posses? Generally speaking, the request adapter holds all the configuration for the client. (auth, serialization, base url, etc...) |
Hi, At present I am using my option (2) - create multiple ApiClients in a dictionary to get the correct one for the call I was rather hoping to just be able to have a single ApiClient rather than multiple, everything else other than the BaseUrl seems configurable via the RequestOptions. |
You could achieve that via a custom middleware handler and the associated option. But I question whether this is desirable: you'll effectively end up mixing the environment switching logic with the application logic. Instead this could/should be handled by the configuration layer/through dependency injection. |
Hi, I'm building the clients through a factory as I could potentially need to add a new endpoint address and I want to do that dynamically whilst the application is running if needed. |
Hi,
I have a number of services that I use which share the same interface but use different base addresses. For instance a Live and Test service. There are reasons for the system to communicate with both systems rather than just one or the other.
Unless I am missing something we either have to set the baseurl at the time of the client creation, or override the entire Url in the call using .WithUrl()
It would seem to be so much simpler to have a .WithBaseUrl() option to just override the base address for this, and looking at the code it seems like it would be simple enough to implement.
At present the options for this appear to be:
These all seem suboptimal compared to having a .WithBaseUrl() option.
Thoughts?
The text was updated successfully, but these errors were encountered: