-
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!
Why use a custom JSON parser here? The modern
System.Text.Jsonclasses are highly performant.Why instantiate an
HttpClientdirectly? 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.LogicalHandlerandSystem.Net.Http.HttpClient.Default.ClientHandlerwhich 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!