You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why use a custom JSON parser here? The modern System.Text.Json classes are highly performant.
Why instantiate an HttpClient directly? The recommended approach ([1], [2]) is to delegate that to the container, and typically resolve IHttpClientFactory. That avoids all sorts of problems like network issues and IIRC a socket exhaustion problem that was prevalent a few versions back. Amongst various benefits, it allows the consumer to
create a custom client and couple that with Polly for resilience
create a named/typed client so logs are more descriptive and can be filtered (else all are logged as System.Net.Http.HttpClient.Default.LogicalHandler and System.Net.Http.HttpClient.Default.ClientHandler which cannot be differentiated from other HttpClient logs)
I assume one should register the service thusly: services.AddSingleton<TurnstileService>()?
BTW: these are not criticisms, just curious and/or looking for advice... Thanks!
The text was updated successfully, but these errors were encountered:
Why use a custom JSON parser here? The modern
System.Text.Json
classes are highly performant.Why instantiate an
HttpClient
directly? The recommended approach ([1], [2]) is to delegate that to the container, and typically resolveIHttpClientFactory
. That avoids all sorts of problems like network issues and IIRC a socket exhaustion problem that was prevalent a few versions back. Amongst various benefits, it allows the consumer toSystem.Net.Http.HttpClient.Default.LogicalHandler
andSystem.Net.Http.HttpClient.Default.ClientHandler
which cannot be differentiated from other HttpClient logs)I assume one should register the service thusly:
services.AddSingleton<TurnstileService>()
?BTW: these are not criticisms, just curious and/or looking for advice... Thanks!
The text was updated successfully, but these errors were encountered: