Skip to content

ChrisonSimtian/Scrutor.Extensions.HttpClient

Repository files navigation

Scrutor.Extensions.HttpClient

A solution for khellang/Scrutor#180 baked into a Nuget Package

Usage

  1. Inject your Http Client as a named Client
  2. Make sure that all your Api Clients are assignable to a common interface
  3. Register all your Api Clients with Scrutor.Extensions.HttpClient
/* Inject named HttpClient */
services.AddHttpClient("MyHttpClient", client =>
{
	client.BaseAddress = new Uri("https://api.example.com");
});

/* Inject all implementations of IMyHttpApiClient */
services.Scan(scan => scan
        .FromCallingAssembly()
        .AddClasses(classes => classes.AssignableTo<IMyHttpApiClient>())
        .AsMatchingInterface()
        .AsHttpClient("MyHttpClient")
        );

Releases

No releases published

Packages

No packages published

Languages