Skip to content

Add IHttpClientFactory integration for ASP.NET Core compatibility #29

Description

@tw4

Summary

Nexar creates its own HttpClient instances internally, which is not compatible with the recommended IHttpClientFactory pattern in ASP.NET Core. This leads to socket exhaustion issues in long-running applications.

Problem

  • No DI (Dependency Injection) friendly constructor
  • Cannot plug into named or typed HTTP clients registered via IHttpClientFactory
  • Not compatible with ASP.NET Core's built-in resilience and retry pipelines (e.g., Polly)

Proposed Solution

  • Add a constructor overload that accepts an HttpClient instance
  • Provide extension methods for IServiceCollection to register Nexar with DI
// Registration
services.AddNexar(config => {
    config.BaseUrl = "https://api.example.com";
});

// Usage via DI
public class MyService(INexar nexar) { }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions