Esempio n. 1
0
        /// <summary>
        /// 限流中间件
        /// </summary>
        /// <param name="services"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static IServiceCollection AddRateLimiting(this IServiceCollection services, Action <RateLimitOptions> options = null)
        {
            var opts = new RateLimitOptions();

            options?.Invoke(opts);
            services.AddSingleton(opts);
            services.AddSingleton <RateLimitProcessor>();
            return(services);
        }