stefanprodan / AspNetCoreRateLimit

ASP.NET Core rate limiting middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to load client rules on execution, not startup

bugnuker opened this issue · comments

Hello,

I have a need to use a rate limiting middleware or some other solution that can limit by client id (or the client id is whitelisted).

This solution seems to fit the bill, however, I can only find methods to load the configuration from appsettings.json OR from a database, but only at startup.

I have a need to be able to add rules at anytime (for example, a new client signed up) - not just startup of the application.

It seems like it would have to be something along the lines of:

try to find the client id in the existing rule list that is cached
if found, execute rules
if not found, try to find a new set of rules

OR

find rule by client id and have a SeedRuleByClientId() method that can pass the client id and the rules can be dynamically loaded for that client. Again, cache should be used to avoid multiple database calls.

How could this be accomplished?