Description
Is your feature request related to a problem? Please describe.
When trying to instantiate more than one Refit client, that both derive from a base interface, I am looking for a way to specify the resource name for each of these individual clients, when using the HttpClient constructor.
For example:
public interface IGetAPI<TEntity>
{
[Get("/{key}")]
Task<TEntity> Get(long key);
}
public interface IUsersAPI : IGetAPI<User>
{
}
public interface IOrdersAPI : IGetAPI<Order>
{
}
public class SomeIntegrationTest
{
public void TestGet()
{
HttpClient httpClient = new WebApplicationFactory(connectionString).CreateClient();
IUsersClient usersClient = RestService.For<IUsersAPI>(httpClient);
IOrdersClient ordersClient = RestService.For<IOrdersAPI>(httpClient);
...
}
}
Since both clients are based on the same HttpClient, and both are derived from the same interface, there is no way to specify the resource name in addition to the base address, i.e. localhost/users.
Describe the solution you'd like
The possibility to specify a resource name when instantiating a client with HttpClient.
Describe alternatives you've considered
The alternatives are to either specify an url instead of HttpClient, or instantiate a seperate HttpClient for each resource. However, both are not possible in my specific situation.
Describe suggestions on how to achieve the feature
An overload on RestService.For<>(), or a property in RefitSettings, to specify the resource name.