GM.Gateway 1.0.0

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

GM.Gateway

A YARP-based API gateway for the GM.* ecosystem with distributed rate limiting enforced at the edge. One call wires a YARP reverse proxy from configuration together with GM.RateLimiting; each route opts into a policy via route metadata, and requests are limited before they are proxied — centrally, across every gateway instance.

Install

dotnet add package GM.Gateway

Wire it up

var builder = WebApplication.CreateBuilder(args);

// Counter store + concurrency (in-memory here; use the Redis variants for cross-instance limits).
builder.Services.AddGMCaching();
builder.Services.AddGMDistributedLock();
// For production: AddGMRedisCaching(...) + AddGMRedisRateLimitStore(...) — lock-free, atomic.

// YARP reverse proxy + GM rate limiting, both from configuration.
builder.Services.AddGMGateway(builder.Configuration);

var app = builder.Build();
app.UseRouting();
app.MapGMGateway();     // reverse proxy with the per-route rate-limit step in its pipeline
app.Run();

Configure routes (and their limits) in appsettings

A route opts into rate limiting purely through its YARP Metadata:

{
  "ReverseProxy": {
    "Routes": {
      "orders": {
        "ClusterId": "orders",
        "Match": { "Path": "/orders/{**catch-all}" },
        "Metadata": { "RateLimitPolicy": "api", "RateLimitPartition": "Ip,Endpoint" }
      }
    },
    "Clusters": {
      "orders": { "Destinations": { "d1": { "Address": "http://orders-service/" } } }
    }
  },
  "RateLimiting": {
    "Policies": {
      "api": { "Algorithm": "SlidingWindow", "PermitLimit": 100, "Window": "00:01:00" }
    }
  }
}
  • RateLimitPolicy — a named policy from RateLimiting:Policies (fixed window / sliding window / token bucket; see GM.RateLimiting).
  • RateLimitPartition — one or more of User, ApiKey, Ip, Endpoint (combine with , or |). Omitted → the middleware's default partition. Routes with no RateLimitPolicy proxy unlimited.

When a route's limit is exceeded the gateway returns 429 Too Many Requests with Retry-After, X-RateLimit-* headers, and a ProblemDetails body — the backend is never called. Because the gateway reuses GM.RateLimiting.Http's IRateLimitEnforcer, these responses are identical to in-app limiting.

Why at the edge

ASP.NET Core's built-in limiter is per-process; behind a scaled-out gateway that means each replica counts separately. GM.Gateway counts in a shared store (GM.Caching, made atomic by GM.DistributedLock or the lock-free GM.RateLimiting.Redis Lua store), so a limit is a limit no matter how many gateway instances are running.

API

  • IServiceCollection.AddGMGateway(configuration, reverseProxySection = "ReverseProxy", rateLimitingSection = "RateLimiting", configureHttp?)IReverseProxyBuilder (chain YARP config).
  • IEndpointRouteBuilder.MapGMGateway() — maps the proxy with rate limiting in its pipeline.
  • IReverseProxyApplicationBuilder.UseGMGatewayRateLimiting() — the pipeline step, for custom proxy pipelines.
  • GatewayRouteMetadata.RateLimitPolicy / .RateLimitPartition — the metadata keys.

Samples

GM.Gateway.Samples — a runnable gateway + backend.

License

MIT — see LICENSE.

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.0.0 86 8/5/2026