public ThrottleService( ILoggerFactory loggerFactory, IEnumerable <IRequirementHandler> handlers, IEnumerable <IExclusionHandler> exclusionHandlers, ISystemClock clock, IThrottleCounterStore store, IOptions <ThrottleOptions> options, ConfigureOptions <ThrottleOptions> configureOptions = null) { if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } if (handlers == null) { throw new ArgumentNullException(nameof(handlers)); } if (exclusionHandlers == null) { throw new ArgumentNullException(nameof(exclusionHandlers)); } if (clock == null) { throw new ArgumentNullException(nameof(clock)); } if (store == null) { throw new ArgumentNullException(nameof(store)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } _options = options.Value; if (configureOptions != null) { configureOptions.Configure(_options); } _options.BuildPolicies(); _handlers = handlers.ToArray(); _exclusionHandlers = exclusionHandlers.ToArray(); _logger = loggerFactory.CreateLogger <ThrottleService>(); _clock = clock; _store = store; }
public ThrottleContext(HttpContext httpContext, ThrottleStrategy strategy, IThrottleCounterStore store) { if (httpContext == null) { throw new ArgumentNullException(nameof(httpContext)); } if (strategy == null) { throw new ArgumentNullException(nameof(strategy)); } HttpContext = httpContext; Requirements = strategy.Policy.Requirements; Exclusions = strategy.Policy.Exclusions; RouteTemplate = strategy.RouteTemplate; _pendingRequirements = new HashSet <IThrottleRequirement>(Requirements); Store = store; }
public LimitsMiddleware(RequestDelegate next, IThrottleCounterStore store) { _next = next; _store = store; }