nclient / NClient

:dizzy: NClient is an automatic type-safe .Net HTTP client that allows you to call web service API methods using annotated interfaces or controllers without boilerplate code.
Apache License 2.0
43 stars 11 forks source link

Named client #427

Open smolchanovsky opened 2 years ago

smolchanovsky commented 2 years ago

A named client will allow you to use named options when creating via DI:

services.Configure<JsonSerializerOptions>(name: "myClient", options =>
{
    options.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
});
services.AddNClient<IFileClient>(name: "myClient", host: "http://localhost:5001");    // Use myClient JsonSerializerOptions
Kingmidas74 commented 1 year ago

I really don't sure that is a good opportunity.
First of all how many times do you re-use options? I think we can just create override AddNClient with options default parameter or extension method WithOptions (if it isn't exist) Secondly, string const make me sad every time I've see this. Pure refactoring ability is breaking. And last but not least... The "name" can be used for any different connections. So... How you suggest resolve the situation when we want to apply same options by name but for multiple clients?