HappyEntity.Refit.Composite
2.1.1
dotnet add package HappyEntity.Refit.Composite --version 2.1.1
NuGet\Install-Package HappyEntity.Refit.Composite -Version 2.1.1
<PackageReference Include="HappyEntity.Refit.Composite" Version="2.1.1" />
<PackageVersion Include="HappyEntity.Refit.Composite" Version="2.1.1" />
<PackageReference Include="HappyEntity.Refit.Composite" />
paket add HappyEntity.Refit.Composite --version 2.1.1
#r "nuget: HappyEntity.Refit.Composite, 2.1.1"
#:package HappyEntity.Refit.Composite@2.1.1
#addin nuget:?package=HappyEntity.Refit.Composite&version=2.1.1
#tool nuget:?package=HappyEntity.Refit.Composite&version=2.1.1
Refit.Composite 
A lightweight, high-performance architectural wrapper for Refit that orchestrates multiple isolated API contracts into unified, Scoped composite services with sophisticated message handler pipeline management.
Features
- 🏎️ High Performance: Compile-time Source Generator orchestration powered by a hardware-level Lock-Free cache with absolutely zero allocations on subsequent property resolutions.
- 🧩 Clean Architecture: Group isolated Refit interfaces into single unified contracts without boilerplate abstract classes or manual dependency factories.
- 🛡️ Declarative Pipeline Control: Manage individual
DelegatingHandlerchains using native C# 12+ generic attributes directly over API definitions. - 🚀 Native AOT & Blazor WASM: 100% compatible with Ahead-Of-Time compilation and browser environments out of the box, producing zero runtime compilation or formatting warnings.
- 🪵 Built-in Quality of Life: Seamless, out-of-the-box integration with high-speed, status-code-aware HTTP logging handlers.
Installation
Install the package via NuGet Package Manager CLI:
dotnet add package HappyEntity.Refit.Composite
Quick Start
1. Define Your Refit Contracts & Composite Interface
Declare your single micro-interfaces using standard Refit attributes. Then, compose them into an aggregate interface inheriting from IRefitComposite. You can assign HTTP handlers globally or to specific endpoints using contemporary generic attributes:
using Refit;
using Refit.Composite;
using Refit.Composite.Attributes;
// Applied globally: executes for both Test and Users endpoints
[ApiHandler<AntiforgeryHandler>]
public interface IMyCompositeApi : IRefitComposite
{
// Inherits global handlers + built-in ShortLoggingHandler
ITestApi Test { get; }
// Overrides pipeline: resets all accumulated handlers and applies ONLY CustomLoggingHandler
[ApiIgnoreAllHandlers]
[ApiHandler<CustomLoggingHandler>]
IUserApi Users { get; }
}
public interface ITestApi
{
[Get("/posts/1")]
Task<string> GetPostAsync();
}
public interface IUserApi
{
[Get("/users/1")]
Task<string> GetUserAsync();
}
2. Register via Dependency Injection
Invoke the registration extension within your application bootstrap (Program.cs). The library takes care of building independent HttpClient configurations for every inner interface contract and safely mounts the Dynamic Proxy:
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection();
// Explicitly register your custom pipeline dependencies
services.AddTransient<AntiforgeryHandler>();
services.AddTransient<CustomLoggingHandler>();
// Boot up the composite workspace
services.AddRefitComposite<IMyCompositeApi>("https://jsonplaceholder.typicode.com/");
var provider = services.BuildServiceProvider();
3. Resolve and Execute
Consume the unified interface through standard constructor injection like any ordinary Scoped service:
var composite = provider.GetRequiredService<IMyCompositeApi>();
// Seamless execution over high-performance lock-free hardware cache
string postData = await composite.Test.GetPostAsync();
Console.WriteLine(postData);
Pipeline Priority Engine
Attributes are processed linearly from top to bottom, providing complete granularity over HTTP message handler setup:
[ApiHandler<T>]— appends a specificDelegatingHandlerto the active execution queue.[ApiIgnoreHandler<T>]— surgically drops an upstream-declared handler from the active property sequence.[ApiIgnoreAllHandlers]— completely flushes the configuration timeline up to its line of declaration.
License
This project is licensed under the MIT License — see the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Refit.HttpClientFactory (>= 11.0.0 && < 12.0.0)
-
.NETStandard 2.0
- Refit.HttpClientFactory (>= 11.0.0 && < 12.0.0)
-
net10.0
- Refit.HttpClientFactory (>= 11.0.0 && < 12.0.0)
-
net8.0
- Refit.HttpClientFactory (>= 11.0.0 && < 12.0.0)
-
net9.0
- Refit.HttpClientFactory (>= 11.0.0 && < 12.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.