GatewayGuard 1.0.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package GatewayGuard --version 1.0.0
                    
NuGet\Install-Package GatewayGuard -Version 1.0.0
                    
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="GatewayGuard" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GatewayGuard" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="GatewayGuard" />
                    
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 GatewayGuard --version 1.0.0
                    
#r "nuget: GatewayGuard, 1.0.0"
                    
#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 GatewayGuard@1.0.0
                    
#: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=GatewayGuard&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=GatewayGuard&version=1.0.0
                    
Install as a Cake Tool

GatewayGuard

GatewayGuard is a lightweight ASP.NET Core library that provides best-effort idempotency guarantees for HTTP requests. It coordinates concurrent requests that share an idempotency key, caches responses for replay, and integrates with OpenTelemetry-compatible metrics.

This repository contains the library (src/GatewayGuard), integration tests (tests/GatewayGuard.Tests), and benchmark scenarios (tests/GatewayGuard.Benchmarks).

Key features

  • Middleware-based idempotency for configurable HTTP methods (POST by default).
  • Client-provided idempotency header or request fingerprinting when header is missing.
  • In-process deduplication (SingleFlight) and distributed coordination via IIdempotencyStore implementations (Redis provided).
  • Configurable limits to avoid caching very large responses.
  • Library-level metrics via System.Diagnostics.Metrics (OpenTelemetry compatible).

Prerequisites

  • .NET 10 SDK
  • Redis (optional for full integration; the sample app and tests may expect a Redis instance)

Quick build & test

From the repository root:

  • Build: dotnet build
  • Run tests: dotnet test
  • Run benchmarks (requires BenchmarkDotNet tooling): open the tests/GatewayGuard.Benchmarks project and run via Visual Studio or dotnet run in that project.

Example: wire into an ASP.NET Core app

See docs/usage.md for a complete example (Prometheus exporter sample). In short:

  1. In Program.cs, register GatewayGuard:
builder.Services.AddGatewayGuard(options =>
{
    options.IdempotencyHeaderName = "X-Idempotency-Key";
    options.EnableFingerprinting = true;
    options.KeyScopeResolver = ctx => ctx.User.Identity?.Name ?? ""; // Secure multi-tenant keys
    options.RedisConnection = "localhost:6379"; // production: secure and configure appropriately
});

app.UseGatewayGuard();
  1. Configure metrics in the host app (optional): call AddMeter("GatewayGuard") when configuring OpenTelemetry so library instruments are collected.

Documentation

  • Architecture overview: docs/architecture.md
  • Usage and examples: docs/usage.md
  • Performance benchmarks: docs/benchmarks.md

Contribution

Contributions are welcome. Please follow these guidelines:

  • Run and update unit/integration tests for behavioral changes.
  • Keep public APIs documented with XML comments. Consider enabling XML doc warnings in CI (CS1591).
  • Keep metric label cardinality low; do not use idempotency keys or request bodies as tags.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET 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. 
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
1.1.0-rc.3 61 4/1/2026
1.1.0-rc.2 59 3/20/2026
1.1.0-rc.1 61 3/20/2026
1.0.0 108 4/2/2026
1.0.0-rc.1 69 3/18/2026