Closed vmachacek closed 2 years ago
Can't you just include this basePath when you create a client?
services
.AddRefitClient<MyClientType>()
.ConfigureHttpClient(c =>
{
c.BaseAddress = new Uri("https://whatever.com/my/api/v1/");
})
If I'm not mistaken this won't work with Refit because Refit requires URL start with /
and thus what you sent as example would end up being https://whatever.com/my/api/v1//foo-bar
considering Refit API would be decorated with [Get("/foo-bar")]
.
To elaborate on my use case Im using tool to generate API for testing and in some scenarios Im using WebApplicationFactory
to run the API. This solved my issue
factory = new WebApplicationFactory();
factory.CreateDefaultClient(new Uri("http://localhost/api"), handlers);
No need for a base path, thanks!
Would it be possible to add command line switch to supply base path string so that every url generated by the tool starts with this base path?
I can take a look and produce a PR..