Flagsmith / flagsmith-dotnet-client

.NET Standard Client for Flagsmith. Ship features with confidence using feature flags and remote config. Host yourself or use our hosted version at https://www.flagsmith.com/
https://www.flagsmith.com/
BSD 3-Clause "New" or "Revised" License
19 stars 12 forks source link

Question: DI registration example #80

Open vpetrusevici opened 8 months ago

vpetrusevici commented 8 months ago

Hi guys! I see in the example you register Flagsmith client as singleton, but in fact this is a typed httpclient. Is it better to use this approach mb?

services.Configure<FlagsmithConfiguration>(builder.Configuration.GetSection(nameof(FlagsmithConfiguration)));
services.AddHttpClient<IFlagsmithClient, FlagsmithClient>(nameof(FlagsmithClient));

Because static/singleton HttpClient doesn't respect DNS changes and is considered bad practice. See details here

novakzaballa commented 8 months ago

@vpetrusevici thank you for bringing this to our attention. We will consider your comments. If you like to build a PR with the proposed changes it would be also much appreciated.