Пример #1
0
        public IpThrottleMiddleware(RequestDelegate next, ThrottleOptions options, ICounterStore counterStore, ILogger <IdThrottleMiddleware> logger)
            : base(next, options, counterStore, logger)
        {
            var matcher = new IpAddressRuleMatcher(Options.ClientWhitelist, Options.ClientPolicies);

            Processor = new ThrottleProcessor(Options, counterStore, matcher);
        }
Пример #2
0
        public static ThrottleProcessor GetProcessorWithWhitelist(string whitelistedClientId, string whitelistedEndpoint)
        {
            var store   = new FakeCounterStore();
            var options = new BasicOptions
            {
                ClientWhitelist = new List <string> {
                    whitelistedClientId
                },
                EndpointWhitelist = new List <string> {
                    whitelistedEndpoint
                }
            };
            var matcher   = new ClientIdRuleMatcher(options.ClientWhitelist, options.ClientPolicies, options.IdIgnoreCase);
            var processor = new ThrottleProcessor(options, store, matcher);

            return(processor);
        }