mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 19:32:52 +08:00
68 lines
2.6 KiB
C#
68 lines
2.6 KiB
C#
using System.IO;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Ocelot.DependencyInjection;
|
|
using Ocelot.Middleware;
|
|
|
|
namespace Ocelot.ManualTest
|
|
{
|
|
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")
|
|
|
|
//.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();
|
|
})
|
|
.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();
|
|
}
|
|
}
|
|
}
|