mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 15:10:50 +08:00 
			
		
		
		
	removed some async we dont need
This commit is contained in:
		@@ -1,11 +1,9 @@
 | 
				
			|||||||
using System.Threading.Tasks;
 | 
					using Ocelot.Responses;
 | 
				
			||||||
using Ocelot.Configuration.File;
 | 
					 | 
				
			||||||
using Ocelot.Responses;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ocelot.Configuration.Provider
 | 
					namespace Ocelot.Configuration.Provider
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public interface IOcelotConfigurationProvider
 | 
					    public interface IOcelotConfigurationProvider
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Task<Response<IOcelotConfiguration>> Get();
 | 
					        Response<IOcelotConfiguration> Get();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,4 @@
 | 
				
			|||||||
using System.Threading.Tasks;
 | 
					using Ocelot.Configuration.Repository;
 | 
				
			||||||
using Ocelot.Configuration.File;
 | 
					 | 
				
			||||||
using Ocelot.Configuration.Repository;
 | 
					 | 
				
			||||||
using Ocelot.Responses;
 | 
					using Ocelot.Responses;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ocelot.Configuration.Provider
 | 
					namespace Ocelot.Configuration.Provider
 | 
				
			||||||
@@ -17,9 +15,9 @@ namespace Ocelot.Configuration.Provider
 | 
				
			|||||||
            _config = repo;
 | 
					            _config = repo;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public async Task<Response<IOcelotConfiguration>> Get()
 | 
					        public Response<IOcelotConfiguration> Get()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var repoConfig = await _config.Get();
 | 
					            var repoConfig = _config.Get();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (repoConfig.IsError)
 | 
					            if (repoConfig.IsError)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@@ -29,4 +27,4 @@ namespace Ocelot.Configuration.Provider
 | 
				
			|||||||
            return new OkResponse<IOcelotConfiguration>(repoConfig.Data);
 | 
					            return new OkResponse<IOcelotConfiguration>(repoConfig.Data);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,6 +5,7 @@ using Consul;
 | 
				
			|||||||
using Newtonsoft.Json;
 | 
					using Newtonsoft.Json;
 | 
				
			||||||
using Ocelot.Configuration.File;
 | 
					using Ocelot.Configuration.File;
 | 
				
			||||||
using Ocelot.Infrastructure.Consul;
 | 
					using Ocelot.Infrastructure.Consul;
 | 
				
			||||||
 | 
					using Ocelot.Logging;
 | 
				
			||||||
using Ocelot.Responses;
 | 
					using Ocelot.Responses;
 | 
				
			||||||
using Ocelot.ServiceDiscovery.Configuration;
 | 
					using Ocelot.ServiceDiscovery.Configuration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -15,16 +16,22 @@ namespace Ocelot.Configuration.Repository
 | 
				
			|||||||
        private readonly ConsulClient _consul;
 | 
					        private readonly ConsulClient _consul;
 | 
				
			||||||
        private const string OcelotConfiguration = "OcelotConfiguration";
 | 
					        private const string OcelotConfiguration = "OcelotConfiguration";
 | 
				
			||||||
        private readonly Cache.IOcelotCache<FileConfiguration> _cache;
 | 
					        private readonly Cache.IOcelotCache<FileConfiguration> _cache;
 | 
				
			||||||
 | 
					        private readonly IOcelotLogger _logger;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public ConsulFileConfigurationRepository(
 | 
					        public ConsulFileConfigurationRepository(
 | 
				
			||||||
            Cache.IOcelotCache<FileConfiguration> cache, 
 | 
					            Cache.IOcelotCache<FileConfiguration> cache,
 | 
				
			||||||
            ServiceProviderConfiguration serviceProviderConfig, 
 | 
					            ServiceProviderConfiguration serviceProviderConfiguration, 
 | 
				
			||||||
            IConsulClientFactory factory)
 | 
					            IConsulClientFactory factory,
 | 
				
			||||||
 | 
					            IOcelotLoggerFactory loggerFactory)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var consulHost = string.IsNullOrEmpty(serviceProviderConfig?.Host) ? "localhost" : serviceProviderConfig?.Host;
 | 
					            _logger = loggerFactory.CreateLogger<ConsulFileConfigurationRepository>();
 | 
				
			||||||
            var consulPort = serviceProviderConfig?.Port ?? 8500;
 | 
					 | 
				
			||||||
            var config = new ConsulRegistryConfiguration(consulHost, consulPort, OcelotConfiguration, serviceProviderConfig?.Token);
 | 
					 | 
				
			||||||
            _cache = cache;
 | 
					            _cache = cache;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var consulHost = string.IsNullOrEmpty(serviceProviderConfiguration?.Host) ? "localhost" : serviceProviderConfiguration?.Host;
 | 
				
			||||||
 | 
					            var consulPort = serviceProviderConfiguration?.Port ?? 8500;
 | 
				
			||||||
 | 
					            var token = serviceProviderConfiguration?.Token;
 | 
				
			||||||
 | 
					            var config = new ConsulRegistryConfiguration(consulHost, consulPort, OcelotConfiguration, token);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            _consul = factory.Get(config);
 | 
					            _consul = factory.Get(config);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,12 +1,10 @@
 | 
				
			|||||||
using System.Threading.Tasks;
 | 
					using Ocelot.Responses;
 | 
				
			||||||
using Ocelot.Configuration.File;
 | 
					 | 
				
			||||||
using Ocelot.Responses;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ocelot.Configuration.Repository
 | 
					namespace Ocelot.Configuration.Repository
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public interface IOcelotConfigurationRepository
 | 
					    public interface IOcelotConfigurationRepository
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Task<Response<IOcelotConfiguration>> Get();
 | 
					        Response<IOcelotConfiguration> Get();
 | 
				
			||||||
        Task<Response> AddOrReplace(IOcelotConfiguration ocelotConfiguration);
 | 
					        Response AddOrReplace(IOcelotConfiguration ocelotConfiguration);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,19 +12,19 @@ namespace Ocelot.Configuration.Repository
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        private IOcelotConfiguration _ocelotConfiguration;
 | 
					        private IOcelotConfiguration _ocelotConfiguration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public Task<Response<IOcelotConfiguration>> Get()
 | 
					        public Response<IOcelotConfiguration> Get()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            return Task.FromResult<Response<IOcelotConfiguration>>(new OkResponse<IOcelotConfiguration>(_ocelotConfiguration));
 | 
					            return new OkResponse<IOcelotConfiguration>(_ocelotConfiguration);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public Task<Response> AddOrReplace(IOcelotConfiguration ocelotConfiguration)
 | 
					        public Response AddOrReplace(IOcelotConfiguration ocelotConfiguration)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            lock (LockObject)
 | 
					            lock (LockObject)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                _ocelotConfiguration = ocelotConfiguration;
 | 
					                _ocelotConfiguration = ocelotConfiguration;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return Task.FromResult<Response>(new OkResponse());
 | 
					            return new OkResponse();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,8 +12,10 @@ namespace Ocelot.Configuration.Setter
 | 
				
			|||||||
        private readonly IOcelotConfigurationCreator _configCreator;
 | 
					        private readonly IOcelotConfigurationCreator _configCreator;
 | 
				
			||||||
        private readonly IFileConfigurationRepository _repo;
 | 
					        private readonly IFileConfigurationRepository _repo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public FileConfigurationSetter(IOcelotConfigurationRepository configRepo, 
 | 
					        public FileConfigurationSetter(
 | 
				
			||||||
            IOcelotConfigurationCreator configCreator, IFileConfigurationRepository repo)
 | 
					            IOcelotConfigurationRepository configRepo, 
 | 
				
			||||||
 | 
					            IOcelotConfigurationCreator configCreator, 
 | 
				
			||||||
 | 
					            IFileConfigurationRepository repo)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _configRepo = configRepo;
 | 
					            _configRepo = configRepo;
 | 
				
			||||||
            _configCreator = configCreator;
 | 
					            _configCreator = configCreator;
 | 
				
			||||||
@@ -33,7 +35,7 @@ namespace Ocelot.Configuration.Setter
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            if(!config.IsError)
 | 
					            if(!config.IsError)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                await _configRepo.AddOrReplace(config.Data);
 | 
					                _configRepo.AddOrReplace(config.Data);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return new ErrorResponse(config.Errors);
 | 
					            return new ErrorResponse(config.Errors);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,3 @@
 | 
				
			|||||||
using Butterfly.Client.Tracing;
 | 
					 | 
				
			||||||
using Microsoft.Extensions.Options;
 | 
					 | 
				
			||||||
using Ocelot.Middleware.Multiplexer;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace Ocelot.DependencyInjection
 | 
					namespace Ocelot.DependencyInjection
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    using CacheManager.Core;
 | 
					    using CacheManager.Core;
 | 
				
			||||||
@@ -22,7 +18,6 @@ namespace Ocelot.DependencyInjection
 | 
				
			|||||||
    using Ocelot.Configuration.Validator;
 | 
					    using Ocelot.Configuration.Validator;
 | 
				
			||||||
    using Ocelot.DownstreamRouteFinder.Finder;
 | 
					    using Ocelot.DownstreamRouteFinder.Finder;
 | 
				
			||||||
    using Ocelot.DownstreamRouteFinder.UrlMatcher;
 | 
					    using Ocelot.DownstreamRouteFinder.UrlMatcher;
 | 
				
			||||||
    using Ocelot.DownstreamUrlCreator;
 | 
					 | 
				
			||||||
    using Ocelot.DownstreamUrlCreator.UrlTemplateReplacer;
 | 
					    using Ocelot.DownstreamUrlCreator.UrlTemplateReplacer;
 | 
				
			||||||
    using Ocelot.Headers;
 | 
					    using Ocelot.Headers;
 | 
				
			||||||
    using Ocelot.Infrastructure.Claims.Parser;
 | 
					    using Ocelot.Infrastructure.Claims.Parser;
 | 
				
			||||||
@@ -44,16 +39,16 @@ namespace Ocelot.DependencyInjection
 | 
				
			|||||||
    using System.Security.Cryptography.X509Certificates;
 | 
					    using System.Security.Cryptography.X509Certificates;
 | 
				
			||||||
    using IdentityServer4.AccessTokenValidation;
 | 
					    using IdentityServer4.AccessTokenValidation;
 | 
				
			||||||
    using Microsoft.AspNetCore.Builder;
 | 
					    using Microsoft.AspNetCore.Builder;
 | 
				
			||||||
    using Microsoft.AspNetCore.Hosting;
 | 
					 | 
				
			||||||
    using Ocelot.Configuration;
 | 
					    using Ocelot.Configuration;
 | 
				
			||||||
    using Ocelot.Configuration.Builder;
 | 
					    using Ocelot.Configuration.Builder;
 | 
				
			||||||
    using FileConfigurationProvider = Ocelot.Configuration.Provider.FileConfigurationProvider;
 | 
					    using FileConfigurationProvider = Ocelot.Configuration.Provider.FileConfigurationProvider;
 | 
				
			||||||
    using Microsoft.Extensions.DependencyInjection.Extensions;
 | 
					    using Microsoft.Extensions.DependencyInjection.Extensions;
 | 
				
			||||||
    using System.Linq;
 | 
					 | 
				
			||||||
    using System.Net.Http;
 | 
					    using System.Net.Http;
 | 
				
			||||||
    using Butterfly.Client.AspNetCore;
 | 
					    using Butterfly.Client.AspNetCore;
 | 
				
			||||||
    using Ocelot.Infrastructure;
 | 
					    using Ocelot.Infrastructure;
 | 
				
			||||||
    using Ocelot.Infrastructure.Consul;
 | 
					    using Ocelot.Infrastructure.Consul;
 | 
				
			||||||
 | 
					    using Butterfly.Client.Tracing;
 | 
				
			||||||
 | 
					    using Ocelot.Middleware.Multiplexer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public class OcelotBuilder : IOcelotBuilder
 | 
					    public class OcelotBuilder : IOcelotBuilder
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,7 +36,7 @@ namespace Ocelot.DownstreamRouteFinder.Middleware
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            var upstreamHost = context.HttpContext.Request.Headers["Host"];
 | 
					            var upstreamHost = context.HttpContext.Request.Headers["Host"];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var configuration = await _configProvider.Get();
 | 
					            var configuration = _configProvider.Get();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (configuration.IsError)
 | 
					            if (configuration.IsError)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +1,7 @@
 | 
				
			|||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
using Microsoft.AspNetCore.Http;
 | 
					 | 
				
			||||||
using Microsoft.Extensions.Primitives;
 | 
					 | 
				
			||||||
using Ocelot.Configuration.Provider;
 | 
					using Ocelot.Configuration.Provider;
 | 
				
			||||||
using Ocelot.DownstreamRouteFinder.Middleware;
 | 
					 | 
				
			||||||
using Ocelot.Infrastructure.Extensions;
 | 
					using Ocelot.Infrastructure.Extensions;
 | 
				
			||||||
using Ocelot.Infrastructure.RequestData;
 | 
					using Ocelot.Infrastructure.RequestData;
 | 
				
			||||||
using Ocelot.Logging;
 | 
					using Ocelot.Logging;
 | 
				
			||||||
@@ -36,7 +33,7 @@ namespace Ocelot.Errors.Middleware
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {               
 | 
					            {               
 | 
				
			||||||
                await TrySetGlobalRequestId(context);
 | 
					                TrySetGlobalRequestId(context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                Logger.LogDebug("ocelot pipeline started");
 | 
					                Logger.LogDebug("ocelot pipeline started");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -56,12 +53,12 @@ namespace Ocelot.Errors.Middleware
 | 
				
			|||||||
            Logger.LogDebug("ocelot pipeline finished");
 | 
					            Logger.LogDebug("ocelot pipeline finished");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private async Task TrySetGlobalRequestId(DownstreamContext context)
 | 
					        private void TrySetGlobalRequestId(DownstreamContext context)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            //try and get the global request id and set it for logs...
 | 
					            //try and get the global request id and set it for logs...
 | 
				
			||||||
            //should this basically be immutable per request...i guess it should!
 | 
					            //should this basically be immutable per request...i guess it should!
 | 
				
			||||||
            //first thing is get config
 | 
					            //first thing is get config
 | 
				
			||||||
            var configuration = await _provider.Get(); 
 | 
					            var configuration = _provider.Get(); 
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            if(configuration.IsError)
 | 
					            if(configuration.IsError)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,6 @@
 | 
				
			|||||||
    using System.Linq;
 | 
					    using System.Linq;
 | 
				
			||||||
    using System.Threading.Tasks;
 | 
					    using System.Threading.Tasks;
 | 
				
			||||||
    using Microsoft.AspNetCore.Hosting;
 | 
					    using Microsoft.AspNetCore.Hosting;
 | 
				
			||||||
    using Microsoft.AspNetCore.Http;
 | 
					 | 
				
			||||||
    using Microsoft.Extensions.Options;
 | 
					    using Microsoft.Extensions.Options;
 | 
				
			||||||
    using System.Diagnostics;
 | 
					    using System.Diagnostics;
 | 
				
			||||||
    using Microsoft.AspNetCore.Builder;
 | 
					    using Microsoft.AspNetCore.Builder;
 | 
				
			||||||
@@ -89,7 +88,7 @@
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            var deps = GetDependencies(builder);
 | 
					            var deps = GetDependencies(builder);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var ocelotConfiguration = await deps.provider.Get();
 | 
					            var ocelotConfiguration = deps.provider.Get();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (ConfigurationNotSetUp(ocelotConfiguration))
 | 
					            if (ConfigurationNotSetUp(ocelotConfiguration))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@@ -101,7 +100,7 @@
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return await GetOcelotConfigAndReturn(deps.provider);
 | 
					            return GetOcelotConfigAndReturn(deps.provider);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private static async Task<Response> SetConfig(IApplicationBuilder builder, IOptions<FileConfiguration> fileConfiguration, IFileConfigurationSetter setter, IOcelotConfigurationProvider provider, IFileConfigurationRepository repo)
 | 
					        private static async Task<Response> SetConfig(IApplicationBuilder builder, IOptions<FileConfiguration> fileConfiguration, IFileConfigurationSetter setter, IOcelotConfigurationProvider provider, IFileConfigurationRepository repo)
 | 
				
			||||||
@@ -137,9 +136,9 @@
 | 
				
			|||||||
            return (fileConfiguration, setter, provider, repo);
 | 
					            return (fileConfiguration, setter, provider, repo);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private static async Task<IOcelotConfiguration> GetOcelotConfigAndReturn(IOcelotConfigurationProvider provider)
 | 
					        private static IOcelotConfiguration GetOcelotConfigAndReturn(IOcelotConfigurationProvider provider)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var ocelotConfiguration = await provider.Get();
 | 
					            var ocelotConfiguration = provider.Get();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(ocelotConfiguration == null || ocelotConfiguration.Data == null || ocelotConfiguration.IsError)
 | 
					            if(ocelotConfiguration == null || ocelotConfiguration.Data == null || ocelotConfiguration.IsError)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@@ -187,7 +186,7 @@
 | 
				
			|||||||
                    return new ErrorResponse(ocelotConfig.Errors);
 | 
					                    return new ErrorResponse(ocelotConfig.Errors);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                config = await ocelotConfigurationRepository.AddOrReplace(ocelotConfig.Data);
 | 
					                config = ocelotConfigurationRepository.AddOrReplace(ocelotConfig.Data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (config.IsError)
 | 
					                if (config.IsError)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,8 +28,7 @@ namespace Ocelot.Raft
 | 
				
			|||||||
            _options = options;
 | 
					            _options = options;
 | 
				
			||||||
            _peers = new List<IPeer>();
 | 
					            _peers = new List<IPeer>();
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            //todo - sort out async nonsense..
 | 
					            var config = _provider.Get();
 | 
				
			||||||
            var config = _provider.Get().GetAwaiter().GetResult();
 | 
					 | 
				
			||||||
            foreach (var item in _options.Value.Peers)
 | 
					            foreach (var item in _options.Value.Peers)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var httpClient = new HttpClient();
 | 
					                var httpClient = new HttpClient();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,6 +22,12 @@ namespace Ocelot.ManualTest
 | 
				
			|||||||
                        .AddJsonFile("appsettings.json", true, true)
 | 
					                        .AddJsonFile("appsettings.json", true, true)
 | 
				
			||||||
                        .AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true)
 | 
					                        .AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true)
 | 
				
			||||||
                        .AddJsonFile("ocelot.json")
 | 
					                        .AddJsonFile("ocelot.json")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        //.AddOcelot();
 | 
				
			||||||
 | 
					                        //load all the ocelot.xxx.json files that are not environments from asp.net core
 | 
				
			||||||
 | 
					                        //merge them into megaconfig
 | 
				
			||||||
 | 
					                        //save megaconfig to disk as ocelot.json
 | 
				
			||||||
 | 
					                        //then add to asp.net config stuff..
 | 
				
			||||||
                        .AddEnvironmentVariables();
 | 
					                        .AddEnvironmentVariables();
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
                .ConfigureServices(s => {
 | 
					                .ConfigureServices(s => {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -49,7 +49,7 @@ namespace Ocelot.UnitTests.Configuration
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        private void WhenIGetTheConfiguration()
 | 
					        private void WhenIGetTheConfiguration()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _getResult = _repo.Get().Result;
 | 
					            _getResult = _repo.Get();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void GivenThereIsASavedConfiguration()
 | 
					        private void GivenThereIsASavedConfiguration()
 | 
				
			||||||
@@ -65,7 +65,7 @@ namespace Ocelot.UnitTests.Configuration
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        private void WhenIAddOrReplaceTheConfig()
 | 
					        private void WhenIAddOrReplaceTheConfig()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _result = _repo.AddOrReplace(_config).Result;
 | 
					            _result = _repo.AddOrReplace(_config);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void ThenNoErrorsAreReturned()
 | 
					        private void ThenNoErrorsAreReturned()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,12 +56,12 @@ namespace Ocelot.UnitTests.Configuration
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            _configurationRepository
 | 
					            _configurationRepository
 | 
				
			||||||
                .Setup(x => x.Get())
 | 
					                .Setup(x => x.Get())
 | 
				
			||||||
                .ReturnsAsync(config);
 | 
					                .Returns(config);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void WhenIGetTheConfig()
 | 
					        private void WhenIGetTheConfig()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _result = _ocelotConfigurationProvider.Get().Result;
 | 
					            _result = _ocelotConfigurationProvider.Get();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void TheFollowingIsReturned(Response<IOcelotConfiguration> expected)
 | 
					        private void TheFollowingIsReturned(Response<IOcelotConfiguration> expected)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,7 +79,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
 | 
				
			|||||||
            _config = config;
 | 
					            _config = config;
 | 
				
			||||||
            _provider
 | 
					            _provider
 | 
				
			||||||
                .Setup(x => x.Get())
 | 
					                .Setup(x => x.Get())
 | 
				
			||||||
                .ReturnsAsync(new OkResponse<IOcelotConfiguration>(_config));
 | 
					                .Returns(new OkResponse<IOcelotConfiguration>(_config));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void GivenTheDownStreamRouteFinderReturns(DownstreamRoute downstreamRoute)
 | 
					        private void GivenTheDownStreamRouteFinderReturns(DownstreamRoute downstreamRoute)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -134,7 +134,7 @@ namespace Ocelot.UnitTests.Errors
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            var ex = new Exception("outer", new Exception("inner"));
 | 
					            var ex = new Exception("outer", new Exception("inner"));
 | 
				
			||||||
             _provider
 | 
					             _provider
 | 
				
			||||||
                .Setup(x => x.Get()).ThrowsAsync(ex);
 | 
					                .Setup(x => x.Get()).Throws(ex);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void ThenAnExceptionIsThrown()
 | 
					        private void ThenAnExceptionIsThrown()
 | 
				
			||||||
@@ -146,7 +146,7 @@ namespace Ocelot.UnitTests.Errors
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            var response = new Responses.ErrorResponse<IOcelotConfiguration>(new FakeError());
 | 
					            var response = new Responses.ErrorResponse<IOcelotConfiguration>(new FakeError());
 | 
				
			||||||
            _provider
 | 
					            _provider
 | 
				
			||||||
                .Setup(x => x.Get()).ReturnsAsync(response);
 | 
					                .Setup(x => x.Get()).Returns(response);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void TheRequestIdIsSet(string key, string value)
 | 
					        private void TheRequestIdIsSet(string key, string value)
 | 
				
			||||||
@@ -158,7 +158,7 @@ namespace Ocelot.UnitTests.Errors
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            var response = new Responses.OkResponse<IOcelotConfiguration>(config);
 | 
					            var response = new Responses.OkResponse<IOcelotConfiguration>(config);
 | 
				
			||||||
            _provider
 | 
					            _provider
 | 
				
			||||||
                .Setup(x => x.Get()).ReturnsAsync(response);
 | 
					                .Setup(x => x.Get()).Returns(response);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void GivenAnExceptionWillNotBeThrownDownstream()
 | 
					        private void GivenAnExceptionWillNotBeThrownDownstream()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user