mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 13:10:51 +08:00 
			
		
		
		
	Add ability to specify scheme of ServiceProviderConfiguration
This commit is contained in:
		@@ -244,6 +244,7 @@
 | 
			
		||||
            {
 | 
			
		||||
                ServiceDiscoveryProvider = new FileServiceDiscoveryProvider
 | 
			
		||||
                {
 | 
			
		||||
                    Scheme = "https",
 | 
			
		||||
                    Port = 198,
 | 
			
		||||
                    Host = "blah"
 | 
			
		||||
                }
 | 
			
		||||
 
 | 
			
		||||
@@ -25,6 +25,7 @@
 | 
			
		||||
        private readonly string _serviceName;
 | 
			
		||||
        private readonly int _port;
 | 
			
		||||
        private readonly string _consulHost;
 | 
			
		||||
        private readonly string _consulScheme;
 | 
			
		||||
        private readonly string _fakeConsulServiceDiscoveryUrl;
 | 
			
		||||
        private List<Service> _services;
 | 
			
		||||
        private readonly Mock<IOcelotLoggerFactory> _factory;
 | 
			
		||||
@@ -37,6 +38,7 @@
 | 
			
		||||
            _serviceName = "test";
 | 
			
		||||
            _port = 8500;
 | 
			
		||||
            _consulHost = "localhost";
 | 
			
		||||
            _consulScheme = "https";
 | 
			
		||||
            _fakeConsulServiceDiscoveryUrl = $"http://{_consulHost}:{_port}";
 | 
			
		||||
            _serviceEntries = new List<ServiceEntry>();
 | 
			
		||||
            _factory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
@@ -44,7 +46,7 @@
 | 
			
		||||
            _logger = new Mock<IOcelotLogger>();
 | 
			
		||||
            _factory.Setup(x => x.CreateLogger<Consul>()).Returns(_logger.Object);
 | 
			
		||||
            _factory.Setup(x => x.CreateLogger<PollConsul>()).Returns(_logger.Object);
 | 
			
		||||
            var config = new ConsulRegistryConfiguration(_consulHost, _port, _serviceName, null);
 | 
			
		||||
            var config = new ConsulRegistryConfiguration(_consulScheme, _consulHost, _port, _serviceName, null);
 | 
			
		||||
            _provider = new Consul(config, _factory.Object, _clientFactory);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -74,7 +76,7 @@
 | 
			
		||||
        public void should_use_token()
 | 
			
		||||
        {
 | 
			
		||||
            var token = "test token";
 | 
			
		||||
            var config = new ConsulRegistryConfiguration(_consulHost, _port, _serviceName, token);
 | 
			
		||||
            var config = new ConsulRegistryConfiguration(_consulScheme, _consulHost, _port, _serviceName, token);
 | 
			
		||||
            _provider = new Consul(config, _factory.Object, _clientFactory);
 | 
			
		||||
 | 
			
		||||
            var serviceEntryOne = new ServiceEntry()
 | 
			
		||||
 
 | 
			
		||||
@@ -35,7 +35,7 @@ namespace Ocelot.UnitTests.Consul
 | 
			
		||||
                .WithServiceName("")
 | 
			
		||||
                .Build();
 | 
			
		||||
 | 
			
		||||
            var provider = ConsulProviderFactory.Get(_provider, new ServiceProviderConfiguration("", "", 1, "", "", 1), reRoute);
 | 
			
		||||
            var provider = ConsulProviderFactory.Get(_provider, new ServiceProviderConfiguration("", "", "", 1, "", "", 1), reRoute);
 | 
			
		||||
            provider.ShouldBeOfType<Consul>();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user