You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a more complicated setup, but I've simplified it for the purposes of this question.
Imagine that I want every endpoint to be limited to 5 per 20s. I configure as follows:
options.GeneralRules = new List<RateLimitRule>
{
new RateLimitRule { Endpoint = "*", Period = "20s", Limit = 5 }
};
And that works fine. However, now I want a specific endpoint to be limited either more or less than that. I presumed I would either place it before or after it in the list. However, I cannot seem to get any combination of all/some of these to work. They all result in "Quota exceeded. Maximum allowed: 5 per 20s. Please try again in 11 second(s)." because it appears it is always applying the * rule:
options.GeneralRules = new List<RateLimitRule>
{
new RateLimitRule { Endpoint = "get:foo/bar", Period = "20s", Limit = 1 },
new RateLimitRule { Endpoint = "get:foo/bar", Period = "20s", Limit = 10 },
new RateLimitRule { Endpoint = "*", Period = "20s", Limit = 5 },
new RateLimitRule { Endpoint = "get:foo/bar", Period = "20s", Limit = 1 },
new RateLimitRule { Endpoint = "get:foo/bar", Period = "20s", Limit = 10 },
};
How can I have a general catch-all rule, and then provide exceptions that are either more strict or more loose?
The text was updated successfully, but these errors were encountered:
Based on the source code, the logic is to use the most restrictive limit for each period. This allows you to define a general catch-all rule and more strict rules for specific endpoints. However, you cannot override the general rule with more loose rules for specific endpoints.
I think the endpoint should be defined as get:/foo/bar.
I have a more complicated setup, but I've simplified it for the purposes of this question.
Imagine that I want every endpoint to be limited to 5 per 20s. I configure as follows:
And that works fine. However, now I want a specific endpoint to be limited either more or less than that. I presumed I would either place it before or after it in the list. However, I cannot seem to get any combination of all/some of these to work. They all result in
"Quota exceeded. Maximum allowed: 5 per 20s. Please try again in 11 second(s)."
because it appears it is always applying the*
rule:How can I have a general catch-all rule, and then provide exceptions that are either more strict or more loose?
The text was updated successfully, but these errors were encountered: