KwikNesta.Contracts.Core
1.3.8
dotnet add package KwikNesta.Contracts.Core --version 1.3.8
NuGet\Install-Package KwikNesta.Contracts.Core -Version 1.3.8
<PackageReference Include="KwikNesta.Contracts.Core" Version="1.3.8" />
<PackageVersion Include="KwikNesta.Contracts.Core" Version="1.3.8" />
<PackageReference Include="KwikNesta.Contracts.Core" />
paket add KwikNesta.Contracts.Core --version 1.3.8
#r "nuget: KwikNesta.Contracts.Core, 1.3.8"
#:package KwikNesta.Contracts.Core@1.3.8
#addin nuget:?package=KwikNesta.Contracts.Core&version=1.3.8
#tool nuget:?package=KwikNesta.Contracts.Core&version=1.3.8
KwikNesta.Contracts
A common library of enums, message contracts, and base types shared across services.
It exists to standardize communication and reduce duplication in distributed systems.
Contents
- Enums
AuditDomain,AuditAction,EmailType,OtpType, ...
- Messages
AuditLog,NotificationMessage, ...
- Static Methods
AuditLog.Initialize(string actionBy, Guid domainId, AuditDomain domain, AuditAction action);NotificationMessage.Initialize(string email, string name, string otp, EmailType type, int expirationInMinutes = 10);NotificationMessage.Initialize(string email, string name, EmailType type, string? reason);
- Extension Methods
ToEmailType(this OtpType type);EnumMapper.Map<TSource, TTarget>(source)
- Pagination
enumerableList.Paginate(pageNumber: 2, pageSize: 10);
- **Http Handlers
Installation
dotnet add package KwikNesta.Contracts.Core
🧩 HTTP Handlers Overview
This package provides helpful HttpMessageHandler implementations designed to improve resilience and request handling for service-to-service communication.
🔐 ForwardAuthHeaderHandler
Automatically forwards the Authorization header from the current HTTP context (when available) to outgoing requests. Useful for propagating bearer tokens across internal service calls.
Example:
services.AddTransient<ForwardAuthHeaderHandler>();
services.AddRefitClient<IUserServiceClient>()
.ConfigureHttpClient(c =>
{
c.BaseAddress = new Uri(servers.UserService);
})
.AddHttpMessageHandler<ForwardAuthHeaderHandler>();
This ensures every request made through IUserServiceClient includes the same Authorization header as the incoming HTTP request.
💤 ServiceHttpClientWakeUpHandler
Designed for scenarios where hosted services (e.g., on Render or other free-tier platforms) might be temporarily asleep. This handler retries requests when a “wake-up” or non-JSON HTML response (like a Render loading page) is detected.
Example:
services.AddTransient<ServiceHttpClientWakeUpHandler>();
services.AddHttpClient("PaymentService", client =>
{
client.BaseAddress = new Uri(servers.PaymentService);
client.Timeout = TimeSpan.FromSeconds(120);
})
.AddHttpMessageHandler<ServiceHttpClientWakeUpHandler>();
✅ Automatically retries and delays between attempts until a valid JSON response is received or the retry limit is reached.
⚙️ ServiceRefitWakeUpHandler
A Refit-compatible variant of the wake-up handler for use with strongly-typed Refit clients. It should typically wrap the client outermost so that retries preserve all inner handler behavior (like auth forwarding).
Example:
services.AddTransient<ForwardAuthHeaderHandler>();
services.AddTransient<ServiceRefitWakeUpHandler>();
services.AddRefitClient<IIdentityServiceClient>()
.ConfigureHttpClient(c =>
{
c.BaseAddress = new Uri(servers.IdentityService);
c.Timeout = TimeSpan.FromSeconds(120);
})
.AddHttpMessageHandler(() => new ServiceRefitWakeUpHandler())
.AddHttpMessageHandler<ForwardAuthHeaderHandler>();
Order matters:
ForwardAuthHeaderHandlerattaches the bearer token.ServiceRefitWakeUpHandlerwraps and retries the whole request if the remote service is still “waking up”.
🧠 Summary
| Handler | Purpose | Typical Use |
|---|---|---|
ForwardAuthHeaderHandler |
Propagate auth tokens | API gateway → downstream service |
ServiceHttpClientWakeUpHandler |
Retry for sleeping servers | HttpClientFactory clients |
ServiceRefitWakeUpHandler |
Retry for sleeping servers (Refit) | Refit-based clients |
Pro tip: Combine ForwardAuthHeaderHandler and ServiceRefitWakeUpHandler for maximum reliability in distributed service environments.
⚖ 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 | 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 was computed. 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 was computed. 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. |
-
net8.0
- CSharpTypes.Extensions (>= 1.0.0)
- Hangfire.AspNetCore (>= 1.8.21)
- Refit (>= 8.0.0)
- Refit.HttpClientFactory (>= 8.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on KwikNesta.Contracts.Core:
| Package | Downloads |
|---|---|
|
DiagnosKit.Core
A shared toolkit for cross-cutting concerns such as global error handling and logging. |
|
|
EFCore.DataForge
Entity Framework Core utilities for CRUD, bulk ops, and soft deletes. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.3.8 | 62 | 10/23/2025 |
| 1.3.7 | 123 | 10/18/2025 |
| 1.3.6 | 92 | 10/18/2025 |
| 1.3.5 | 167 | 10/15/2025 |
| 1.3.4 | 157 | 10/14/2025 |
| 1.3.3 | 156 | 10/14/2025 |
| 1.3.2 | 194 | 10/12/2025 |
| 1.3.1 | 174 | 10/4/2025 |
| 1.3.0 | 150 | 10/4/2025 |
| 1.2.9 | 169 | 9/30/2025 |
| 1.2.8 | 167 | 9/28/2025 |
| 1.2.7 | 150 | 9/28/2025 |
| 1.2.6 | 141 | 9/28/2025 |
| 1.2.5 | 140 | 9/7/2025 |
| 1.2.4 | 189 | 8/31/2025 |
| 1.1.5 | 174 | 8/31/2025 |
| 1.1.4 | 176 | 8/31/2025 |
| 1.1.3 | 182 | 8/31/2025 |
| 1.1.2 | 268 | 8/24/2025 |
| 1.1.0 | 90 | 8/23/2025 |
| 1.0.0 | 93 | 8/23/2025 |