mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 19:00:48 +08:00 
			
		
		
		
	dont use dynamic routing unless service discovery provider explictly set and log that we are going to use dynamic info (#437)
* #428 dont use dynamic routing unless service discovery provider explictly set and log that we are going to use dynamic info * #428 fixed tests that were failing due to not maintaining backwards compat with config for service discovery
This commit is contained in:
		@@ -1,61 +1,63 @@
 | 
			
		||||
namespace Ocelot.ManualTest
 | 
			
		||||
{
 | 
			
		||||
    using System.IO;
 | 
			
		||||
    using Microsoft.AspNetCore.Hosting;
 | 
			
		||||
    using Microsoft.Extensions.Logging;
 | 
			
		||||
    using Microsoft.Extensions.Configuration;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using Ocelot.DependencyInjection;
 | 
			
		||||
    using Ocelot.Middleware;
 | 
			
		||||
 | 
			
		||||
    public class Program
 | 
			
		||||
    {
 | 
			
		||||
        public static void Main(string[] args)
 | 
			
		||||
        {
 | 
			
		||||
            new WebHostBuilder()
 | 
			
		||||
                .UseKestrel()
 | 
			
		||||
                .UseContentRoot(Directory.GetCurrentDirectory())
 | 
			
		||||
                .ConfigureAppConfiguration((hostingContext, config) =>
 | 
			
		||||
                {
 | 
			
		||||
                    config
 | 
			
		||||
                        .SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
 | 
			
		||||
                        .AddJsonFile("appsettings.json", true, true)
 | 
			
		||||
                        .AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true)
 | 
			
		||||
                        .AddJsonFile("ocelot.json")
 | 
			
		||||
                        .AddEnvironmentVariables();
 | 
			
		||||
                })
 | 
			
		||||
                .ConfigureServices(s => {
 | 
			
		||||
                     s.AddAuthentication()
 | 
			
		||||
                        .AddJwtBearer("TestKey", x =>
 | 
			
		||||
                        {
 | 
			
		||||
                            x.Authority = "test";
 | 
			
		||||
                            x.Audience = "test";
 | 
			
		||||
                        });
 | 
			
		||||
 | 
			
		||||
                    s.AddOcelot()
 | 
			
		||||
                        .AddCacheManager(x =>
 | 
			
		||||
                        {
 | 
			
		||||
                            x.WithDictionaryHandle();
 | 
			
		||||
                        })
 | 
			
		||||
                      /*.AddOpenTracing(option =>
 | 
			
		||||
                      {
 | 
			
		||||
                          option.CollectorUrl = "http://localhost:9618";
 | 
			
		||||
                          option.Service = "Ocelot.ManualTest";
 | 
			
		||||
                      })*/
 | 
			
		||||
                    .AddAdministration("/administration", "secret");
 | 
			
		||||
                })
 | 
			
		||||
                .ConfigureLogging((hostingContext, logging) =>
 | 
			
		||||
                {
 | 
			
		||||
                    logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
 | 
			
		||||
                    logging.AddConsole();
 | 
			
		||||
                })
 | 
			
		||||
                .UseIISIntegration()
 | 
			
		||||
                .Configure(app =>
 | 
			
		||||
                {
 | 
			
		||||
                    app.UseOcelot().Wait();
 | 
			
		||||
                })
 | 
			
		||||
                .Build()
 | 
			
		||||
                .Run();                
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
namespace Ocelot.ManualTest
 | 
			
		||||
{
 | 
			
		||||
    using System.IO;
 | 
			
		||||
    using Microsoft.AspNetCore.Hosting;
 | 
			
		||||
    using Microsoft.Extensions.Logging;
 | 
			
		||||
    using Microsoft.Extensions.Configuration;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using Ocelot.DependencyInjection;
 | 
			
		||||
    using Ocelot.Middleware;
 | 
			
		||||
    using System;
 | 
			
		||||
    using IdentityServer4.AccessTokenValidation;
 | 
			
		||||
 | 
			
		||||
    public class Program
 | 
			
		||||
    {
 | 
			
		||||
        public static void Main(string[] args)
 | 
			
		||||
        {
 | 
			
		||||
            new WebHostBuilder()
 | 
			
		||||
                .UseKestrel()
 | 
			
		||||
                .UseContentRoot(Directory.GetCurrentDirectory())
 | 
			
		||||
                .ConfigureAppConfiguration((hostingContext, config) =>
 | 
			
		||||
                {
 | 
			
		||||
                    config
 | 
			
		||||
                        .SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
 | 
			
		||||
                        .AddJsonFile("appsettings.json", true, true)
 | 
			
		||||
                        .AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true)
 | 
			
		||||
                        .AddJsonFile("ocelot.json")
 | 
			
		||||
                        .AddEnvironmentVariables();
 | 
			
		||||
                })
 | 
			
		||||
                .ConfigureServices(s => {
 | 
			
		||||
                     s.AddAuthentication()
 | 
			
		||||
                        .AddJwtBearer("TestKey", x =>
 | 
			
		||||
                        {
 | 
			
		||||
                            x.Authority = "test";
 | 
			
		||||
                            x.Audience = "test";
 | 
			
		||||
                        });
 | 
			
		||||
 | 
			
		||||
                    s.AddOcelot()
 | 
			
		||||
                        .AddCacheManager(x =>
 | 
			
		||||
                        {
 | 
			
		||||
                            x.WithDictionaryHandle();
 | 
			
		||||
                        })
 | 
			
		||||
                      /*.AddOpenTracing(option =>
 | 
			
		||||
                      {
 | 
			
		||||
                          option.CollectorUrl = "http://localhost:9618";
 | 
			
		||||
                          option.Service = "Ocelot.ManualTest";
 | 
			
		||||
                      })*/
 | 
			
		||||
                    .AddAdministration("/administration", "secret");
 | 
			
		||||
                })
 | 
			
		||||
                .ConfigureLogging((hostingContext, logging) =>
 | 
			
		||||
                {
 | 
			
		||||
                    logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
 | 
			
		||||
                    logging.AddConsole();
 | 
			
		||||
                })
 | 
			
		||||
                .UseIISIntegration()
 | 
			
		||||
                .Configure(app =>
 | 
			
		||||
                {
 | 
			
		||||
                    app.UseOcelot().Wait();
 | 
			
		||||
                })
 | 
			
		||||
                .Build()
 | 
			
		||||
                .Run();                
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user