Exemplo n.º 1
0
        public TrustIPFilter
            (ILogger <TrustIPFilter> logger, IConfiguration configuration)
        {
            _logger = logger;

            IPHelper.InitByConfiguration(configuration, logger);
        }
        /// <summary>
        /// 启用授信IP
        /// </summary>
        /// <param name="app"></param>
        /// <param name="loggerFactory"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static IApplicationBuilder UseTrustIP(this IApplicationBuilder app, ILoggerFactory loggerFactory, IConfiguration configuration)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            var logger = loggerFactory.CreateLogger <TrustIPMiddleware>();

            IPHelper.InitByConfiguration(configuration, logger);
            return(app.UseMiddleware <TrustIPMiddleware>(logger));
        }