This commit addresses the usage of HttpClient within the middleware. Previously, a new HttpClient was instantiated with each request, which, while functional, could lead to potential issues under high load.
This update leverages ASP.NET Core's built-in IHttpClientFactory for managing HttpClient instances. This factory helps in efficiently managing HttpClient lifecycles, reducing the risk of socket exhaustion, and increasing the overall performance.
Changes include:
Injecting IHttpClientFactory in the middleware's constructor.
Utilizing the factory to create HttpClient instances within the ProxyAsync method.
These modifications ensure a more optimal use of resources and promote better application stability and scalability.
This commit addresses the usage of
HttpClient
within the middleware. Previously, a newHttpClient
was instantiated with each request, which, while functional, could lead to potential issues under high load.This update leverages ASP.NET Core's built-in
IHttpClientFactory
for managingHttpClient
instances. This factory helps in efficiently managingHttpClient
lifecycles, reducing the risk of socket exhaustion, and increasing the overall performance.Changes include:
IHttpClientFactory
in the middleware's constructor.HttpClient
instances within theProxyAsync
method.These modifications ensure a more optimal use of resources and promote better application stability and scalability.