Beispiel #1
0
        public bool ValidateRule(int userId, int requestId, RateLimiterRule rule, List <IRateLimiterFilter> targetFilters, EnumFilterMatchMode filterMatchMode = EnumFilterMatchMode.Any)
        {
            if (rule == null)
            {
                return(true);
            }

            if (rule.FiltersMatched(targetFilters, filterMatchMode))
            {
                return(rule.Strategy.IsAllowed(userId, requestId));
            }

            return(false);
        }
Beispiel #2
0
        public bool ValidateRule(int userId, int requestId, RateLimiterRule rule, IRateLimiterFilter targetFilter = null)
        {
            if (rule == null)
            {
                return(true);
            }
            List <IRateLimiterFilter> targetFilters = targetFilter != null ? new List <IRateLimiterFilter>()
            {
                targetFilter
            } : null;

            if (rule.FiltersMatched(targetFilters))
            {
                return(rule.Strategy.IsAllowed(userId, requestId));
            }

            return(false);
        }