mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 20:50:49 +08:00 
			
		
		
		
	all acceptance tests passing
This commit is contained in:
		@@ -13,13 +13,15 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
        private readonly IHttpHandlerOptionsCreator _httpHandlerOptionsCreator;
 | 
			
		||||
        private readonly IAdministrationPath _adminPath;
 | 
			
		||||
        private readonly ILoadBalancerOptionsCreator _loadBalancerOptionsCreator;
 | 
			
		||||
        private readonly IVersionCreator _versionCreator;
 | 
			
		||||
 | 
			
		||||
        public ConfigurationCreator(
 | 
			
		||||
            IServiceProviderConfigurationCreator serviceProviderConfigCreator,
 | 
			
		||||
            IQoSOptionsCreator qosOptionsCreator,
 | 
			
		||||
            IHttpHandlerOptionsCreator httpHandlerOptionsCreator,
 | 
			
		||||
            IServiceProvider serviceProvider,
 | 
			
		||||
            ILoadBalancerOptionsCreator loadBalancerOptionsCreator
 | 
			
		||||
            ILoadBalancerOptionsCreator loadBalancerOptionsCreator,
 | 
			
		||||
            IVersionCreator versionCreator
 | 
			
		||||
            )
 | 
			
		||||
        {
 | 
			
		||||
            _adminPath = serviceProvider.GetService<IAdministrationPath>();
 | 
			
		||||
@@ -27,6 +29,7 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
            _serviceProviderConfigCreator = serviceProviderConfigCreator;
 | 
			
		||||
            _qosOptionsCreator = qosOptionsCreator;
 | 
			
		||||
            _httpHandlerOptionsCreator = httpHandlerOptionsCreator;
 | 
			
		||||
            _versionCreator = versionCreator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public InternalConfiguration Create(FileConfiguration fileConfiguration, List<ReRoute> reRoutes)
 | 
			
		||||
@@ -41,6 +44,8 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
 | 
			
		||||
            var adminPath = _adminPath != null ? _adminPath.Path : null;
 | 
			
		||||
 | 
			
		||||
            var version = _versionCreator.Create(fileConfiguration.GlobalConfiguration.DownstreamHttpVersion);
 | 
			
		||||
 | 
			
		||||
            return new InternalConfiguration(reRoutes,
 | 
			
		||||
                adminPath,
 | 
			
		||||
                serviceProviderConfiguration,
 | 
			
		||||
@@ -48,7 +53,8 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
                lbOptions,
 | 
			
		||||
                fileConfiguration.GlobalConfiguration.DownstreamScheme,
 | 
			
		||||
                qosOptions,
 | 
			
		||||
                httpHandlerOptions
 | 
			
		||||
                httpHandlerOptions,
 | 
			
		||||
                version
 | 
			
		||||
                );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -8,10 +8,12 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
    public class DynamicsCreator : IDynamicsCreator
 | 
			
		||||
    {
 | 
			
		||||
        private readonly IRateLimitOptionsCreator _rateLimitOptionsCreator;
 | 
			
		||||
        private readonly IVersionCreator _versionCreator;
 | 
			
		||||
 | 
			
		||||
        public DynamicsCreator(IRateLimitOptionsCreator rateLimitOptionsCreator)
 | 
			
		||||
        public DynamicsCreator(IRateLimitOptionsCreator rateLimitOptionsCreator, IVersionCreator versionCreator)
 | 
			
		||||
        {
 | 
			
		||||
            _rateLimitOptionsCreator = rateLimitOptionsCreator;
 | 
			
		||||
            _versionCreator = versionCreator;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public List<ReRoute> Create(FileConfiguration fileConfiguration)
 | 
			
		||||
@@ -26,10 +28,13 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
            var rateLimitOption = _rateLimitOptionsCreator
 | 
			
		||||
                .Create(fileDynamicReRoute.RateLimitRule, globalConfiguration);
 | 
			
		||||
 | 
			
		||||
            var version = _versionCreator.Create(fileDynamicReRoute.DownstreamHttpVersion);
 | 
			
		||||
 | 
			
		||||
            var downstreamReRoute = new DownstreamReRouteBuilder()
 | 
			
		||||
                .WithEnableRateLimiting(rateLimitOption.EnableRateLimiting)
 | 
			
		||||
                .WithRateLimitOptions(rateLimitOption)
 | 
			
		||||
                .WithServiceName(fileDynamicReRoute.ServiceName)
 | 
			
		||||
                .WithDownstreamHttpVersion(version)
 | 
			
		||||
                .Build();
 | 
			
		||||
 | 
			
		||||
            var reRoute = new ReRouteBuilder()
 | 
			
		||||
 
 | 
			
		||||
@@ -4,5 +4,6 @@ namespace Ocelot.Configuration.File
 | 
			
		||||
    {
 | 
			
		||||
        public string ServiceName { get; set; }
 | 
			
		||||
        public FileRateLimitRule RateLimitRule { get; set; }
 | 
			
		||||
        public string DownstreamHttpVersion { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -26,5 +26,7 @@
 | 
			
		||||
        public string DownstreamScheme { get; set; }
 | 
			
		||||
 | 
			
		||||
        public FileHttpHandlerOptions HttpHandlerOptions { get; set; }
 | 
			
		||||
 | 
			
		||||
        public string DownstreamHttpVersion { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,8 @@ using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
 | 
			
		||||
    public interface IInternalConfiguration
 | 
			
		||||
    {
 | 
			
		||||
        List<ReRoute> ReRoutes { get; }
 | 
			
		||||
@@ -19,5 +21,7 @@ namespace Ocelot.Configuration
 | 
			
		||||
        QoSOptions QoSOptions { get; }
 | 
			
		||||
 | 
			
		||||
        HttpHandlerOptions HttpHandlerOptions { get; }
 | 
			
		||||
 | 
			
		||||
        Version DownstreamHttpVersion { get;  }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,8 @@ using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Configuration
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
 | 
			
		||||
    public class InternalConfiguration : IInternalConfiguration
 | 
			
		||||
    {
 | 
			
		||||
        public InternalConfiguration(
 | 
			
		||||
@@ -12,7 +14,8 @@ namespace Ocelot.Configuration
 | 
			
		||||
            LoadBalancerOptions loadBalancerOptions,
 | 
			
		||||
            string downstreamScheme,
 | 
			
		||||
            QoSOptions qoSOptions,
 | 
			
		||||
            HttpHandlerOptions httpHandlerOptions)
 | 
			
		||||
            HttpHandlerOptions httpHandlerOptions,
 | 
			
		||||
            Version downstreamHttpVersion)
 | 
			
		||||
        {
 | 
			
		||||
            ReRoutes = reRoutes;
 | 
			
		||||
            AdministrationPath = administrationPath;
 | 
			
		||||
@@ -22,6 +25,7 @@ namespace Ocelot.Configuration
 | 
			
		||||
            DownstreamScheme = downstreamScheme;
 | 
			
		||||
            QoSOptions = qoSOptions;
 | 
			
		||||
            HttpHandlerOptions = httpHandlerOptions;
 | 
			
		||||
            DownstreamHttpVersion = downstreamHttpVersion;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public List<ReRoute> ReRoutes { get; }
 | 
			
		||||
@@ -32,5 +36,7 @@ namespace Ocelot.Configuration
 | 
			
		||||
        public string DownstreamScheme { get; }
 | 
			
		||||
        public QoSOptions QoSOptions { get; }
 | 
			
		||||
        public HttpHandlerOptions HttpHandlerOptions { get; }
 | 
			
		||||
 | 
			
		||||
        public Version DownstreamHttpVersion { get; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
namespace Ocelot.DownstreamRouteFinder.Finder
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using Configuration;
 | 
			
		||||
    using Configuration.Builder;
 | 
			
		||||
    using Configuration.Creator;
 | 
			
		||||
@@ -54,6 +55,7 @@
 | 
			
		||||
                .WithQosOptions(qosOptions)
 | 
			
		||||
                .WithDownstreamScheme(configuration.DownstreamScheme)
 | 
			
		||||
                .WithLoadBalancerOptions(configuration.LoadBalancerOptions)
 | 
			
		||||
                .WithDownstreamHttpVersion(configuration.DownstreamHttpVersion)
 | 
			
		||||
                .WithUpstreamPathTemplate(upstreamPathTemplate);
 | 
			
		||||
 | 
			
		||||
            var rateLimitOptions = configuration.ReRoutes != null
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user