![]() |
VOOZH | about |
dotnet add package Franz.Common.Http.Refit --version 2.2.7
NuGet\Install-Package Franz.Common.Http.Refit -Version 2.2.7
<PackageReference Include="Franz.Common.Http.Refit" Version="2.2.7" />
<PackageVersion Include="Franz.Common.Http.Refit" Version="2.2.7" />Directory.Packages.props
<PackageReference Include="Franz.Common.Http.Refit" />Project file
paket add Franz.Common.Http.Refit --version 2.2.7
#r "nuget: Franz.Common.Http.Refit, 2.2.7"
#:package Franz.Common.Http.Refit@2.2.7
#addin nuget:?package=Franz.Common.Http.Refit&version=2.2.7Install as a Cake Addin
#tool nuget:?package=Franz.Common.Http.Refit&version=2.2.7Install as a Cake Tool
Package: Franz.Common.Http.Refit
Refit integration for the Franz Framework — production-oriented, small-surface, and highly modular. Provides typed Refit clients pre-wired with correlation and tenant propagation, optional authentication, resilience with Polly, Serilog-friendly logging, and OpenTelemetry-friendly instrumentation.
MediatorContext, correlation IDs, and shared Polly registry).Unified Client Registration
AddFranzRefit<TClient>(...) — single-line registration that configures:
Header Propagation
FranzRefitHeadersHandler automatically injects:
X-Correlation-IDX-Tenant-IdX-User-Id (if available)Authentication Handler
FranzRefitAuthHandler integrates via a pluggable ITokenProvider.
Automatically disables itself if no provider or options are configured.
Resilience Integration
Seamless Polly policy attachment via AddPolicyHandlerFromRegistry.
Telemetry and Metrics
Activity.Current with franz.http.* tags for distributed tracing.System.Diagnostics.Metrics (Meter: Franz.Refit).IHttpClientFactory.dotnet nuget add source "https://your-private-feed-url" \
--name "AzurePrivateFeed" \
--username "YourAzureUsername" \
--password "YourAzurePassword" \
--store-password-in-clear-text
Install the package:
dotnet add package Franz.Common.Http.Refit
using Franz.Common.Http.Refit.Extensions;
builder.Services.AddFranzRefit<IMyExternalApi>(
name: "MyApi",
baseUrl: "https://api.example.com",
policyName: "standard-http-retry",
configureOptions: opt =>
{
opt.EnableOpenTelemetry = true;
opt.DefaultPolicyName = "standard-http-retry";
opt.Timeout = TimeSpan.FromSeconds(30);
});
✅ Automatically configures:
FranzRefitHeadersHandler)FranzRefitAuthHandler, optional)Implement a token provider:
using Franz.Common.Http.Refit.Contracts;
public sealed class MyTokenProvider : ITokenProvider
{
public Task<string?> GetTokenAsync(CancellationToken ct = default)
{
// Fetch from secure store, cache, or identity service
return Task.FromResult("example-token");
}
}
Register it in DI:
builder.Services.AddSingleton<ITokenProvider, MyTokenProvider>();
If no ITokenProvider is registered, the handler auto-disables and no Authorization header is sent.
{
"RefitClientOptions": {
"EnableOpenTelemetry": true,
"DefaultPolicyName": "standard-http-retry",
"Timeout": "00:00:30"
}
}
Wire configuration:
builder.Services.AddFranzRefit<IMyApi>(
name: "MyApi",
baseUrl: builder.Configuration["ExternalApi:BaseUrl"]!,
configureOptions: opt =>
{
builder.Configuration.GetSection("RefitClientOptions").Bind(opt);
});
using Polly;
using Polly.Extensions.Http;
builder.Services.AddPolicyRegistry(registry =>
{
registry.Add("standard-http-retry", HttpPolicyExtensions
.HandleTransientHttpError()
.OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.TooManyRequests)
.WaitAndRetryAsync(3, retry => TimeSpan.FromSeconds(Math.Pow(2, retry))));
});
using Refit;
using System.Threading.Tasks;
public interface IBooksApi
{
[Get("/books")]
Task<ApiResponse<List<BookDto>>> GetBooksAsync();
}
using Franz.Common.Http.Refit.Handlers;
using Microsoft.Extensions.Options;
builder.Services.Configure<DefaultTokenProviderOptions>(builder.Configuration.GetSection("Auth"));
builder.Services.AddHttpClient(nameof(DefaultTokenProvider));
builder.Services.AddSingleton<ITokenProvider, DefaultTokenProvider>();
Example Auth configuration:
{
"Auth": {
"TokenEndpoint": "https://login.example.com/oauth2/token",
"ClientId": "my-client",
"ClientSecret": "my-secret",
"Scope": "api.read"
}
}
This enables a cached OAuth2 token provider without any custom code.
If Franz.Common.Http.Bootstrap is active and Franz:HttpClients:EnableRefit = true,
Refit clients can be registered automatically from configuration:
{
"Franz": {
"HttpClients": {
"EnableRefit": true,
"Apis": {
"Books": {
"InterfaceType": "MyApp.ApiClients.IBooksApi, MyApp",
"BaseUrl": "https://api.example.com",
"Policy": "standard-http-retry"
}
}
}
}
}
🔹 Highlights
Self-Disabling Authentication Handler
FranzRefitAuthHandler now auto-deactivates when no token provider or configuration is present.Unified Refit Registration
AddFranzRefit<TClient>() registration combining Refit setup, Polly, OTEL, and Serilog context propagation.Improved Token Provider Contract
ITokenProvider fully async, nullable token support, integrated fallback provider.OpenTelemetry Support
franz.http.* naming convention.Config Binding
RefitClientOptions (e.g., Timeout, DefaultPolicyName).Default Token Provider
DefaultTokenProvider with client credentials OAuth2 flow support.Better Sandbox Behavior
NoOpTokenProvider when authentication is not required.Together, they provide a fully coherent HTTP and API integration ecosystem under Franz.
This package is internal to the Franz Framework. If you have repository access:
https://github.com/bestacio89/Franz.Common/develop.Licensed under the MIT License (see LICENSE file).
| Scenario | Recommendation |
|---|---|
| No Auth / Sandbox | Do not register ITokenProvider; auth handler disables automatically. |
| Auth APIs | Register ITokenProvider or use DefaultTokenProvider. |
| Resilient APIs | Use Polly policies from the global registry. |
| Observability | Enable OpenTelemetry tagging and use Serilog for structured logs. |
| Configuration | Prefer JSON-bound RefitClientOptions for consistency. |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.2.7 | 92 | 6/7/2026 |
| 2.2.6 | 96 | 6/6/2026 |
| 2.2.5 | 100 | 6/4/2026 |
| 2.2.4 | 93 | 6/3/2026 |
| 2.2.3 | 101 | 6/2/2026 |
| 2.2.2 | 96 | 6/2/2026 |
| 2.2.1 | 96 | 5/24/2026 |
| 2.1.4 | 107 | 4/27/2026 |
| 2.1.3 | 102 | 4/26/2026 |
| 2.1.2 | 100 | 4/26/2026 |
| 2.1.1 | 103 | 4/22/2026 |
| 2.0.2 | 113 | 3/30/2026 |
| 2.0.1 | 116 | 3/29/2026 |
| 1.7.8 | 110 | 3/2/2026 |
| 1.7.7 | 125 | 1/31/2026 |
| 1.7.6 | 132 | 1/22/2026 |
| 1.7.5 | 124 | 1/10/2026 |
| 1.7.4 | 120 | 12/27/2025 |
| 1.7.3 | 203 | 12/22/2025 |
| 1.7.2 | 204 | 12/21/2025 |