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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HappyEntity.Refit.Composite" Version="2.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HappyEntity.Refit.Composite" Version="2.1.1" />
                    
Directory.Packages.props
<PackageReference Include="HappyEntity.Refit.Composite" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add HappyEntity.Refit.Composite --version 2.1.1
                    
#r "nuget: HappyEntity.Refit.Composite, 2.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package HappyEntity.Refit.Composite@2.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=HappyEntity.Refit.Composite&version=2.1.1
                    
Install as a Cake Addin
#tool nuget:?package=HappyEntity.Refit.Composite&version=2.1.1
                    
Install as a Cake Tool

Refit.Composite NuGet Version

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 DelegatingHandler chains 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:

  1. [ApiHandler<T>] — appends a specific DelegatingHandler to the active execution queue.
  2. [ApiIgnoreHandler<T>] — surgically drops an upstream-declared handler from the active property sequence.
  3. [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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.1 48 6/19/2026
2.1.0 42 6/18/2026
2.0.3 45 6/17/2026
2.0.2 46 6/17/2026
2.0.1 45 6/17/2026
2.0.0 48 6/17/2026
1.0.0 42 6/17/2026