/// <summary> /// 用ip策略 /// </summary> /// <param name="options"></param> /// <param name="configure"></param> /// <returns></returns> /// <exception cref="ArgumentNullException"></exception> public static UrlIntercepOptions UseIpStrategy(this UrlIntercepOptions options, Action <IpOptions> configure) { if (configure == null) { throw new ArgumentNullException(nameof(configure)); } options.RegisterExtension(new IpUrlInterceptorOptionsExtension(configure)); return(options); }
/// <summary> /// 添加Url拦截器 /// </summary> /// <param name="services"></param> /// <param name="setupAction"></param> /// <returns></returns> public static IServiceCollection AddUrlInterceptor(this IServiceCollection services, Action <UrlIntercepOptions> setupAction) { if (setupAction == null) { throw new ArgumentNullException(nameof(setupAction)); } UrlIntercepOptions intercepOptions = new UrlIntercepOptions(); setupAction.Invoke(intercepOptions); foreach (var serviceExtension in intercepOptions.Extensions) { serviceExtension.AddServices(services); } services.AddSingleton(intercepOptions); return(services); }