stefanprodan / AspNetCoreRateLimit

ASP.NET Core rate limiting middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"group" endpoints into one rule

davedesantis opened this issue · comments

I have the following configuration:

"ClientRateLimitSettings": {
  "EnableEndpointRateLimiting": true,
  "EnableRegexRuleMatching": true,
  "ClientIdHeader": "X-ClientId",
  "HttpStatusCode": 429,
  "QuotaExceededMessage": "{0}/{1}",
  "GeneralRules": [
    {
      "Endpoint": "get:/api/test",
      "Period": "1m",
      "Limit": 20
    }
  ]
},

The customer wishes to group all endpoints under /api/test under one rule, so basically, if I call GET /api/test/123 20 times, after that requests to GET /api/test/456 and GET /api/test should be blocked, too.

I tried with wildcards, and I tried with RegEx ("Endpoint": "get:/api/test/(.*)"), however it seems like every endpoint (so /123 and /456) is treated separately.

I don't know if I am missing something or if that's really not possible?

Any update?

Solution described here: #78