mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 12:22:50 +08:00
43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
using System.IO;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Ocelot.DependencyInjection;
|
|
using Ocelot.Middleware;
|
|
|
|
namespace OcelotBasic
|
|
{
|
|
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.AddOcelot();
|
|
})
|
|
.ConfigureLogging((hostingContext, logging) =>
|
|
{
|
|
//add your logging
|
|
})
|
|
.UseIISIntegration()
|
|
.Configure(app =>
|
|
{
|
|
app.UseOcelot().Wait();
|
|
})
|
|
.Build()
|
|
.Run();
|
|
}
|
|
}
|
|
}
|