You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
813 B
C#

using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Core.ServiceExtensions;
using DS.WMS.GateWay;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
var builder = WebApplication.CreateBuilder(args);
IConfiguration configuration = new ConfigurationBuilder()
.AddJsonFile("ocelot.json")
.Build();
builder.Services.AddOcelot(configuration);////添加Ocelot服务
builder.Services.AddCorsInstall();
builder.WebHost.UseUrls("http://*:8002");//单个设置
var app = builder.Build();
//跨域
var policyName = AppSetting.Configuration["Cors:PolicyName"];
if (!policyName.IsNullOrEmpty())
{
app.UseCors(policyName); //添加跨域中间件
}
app.MapGet("/", () => "Hello World!");
app.UseMiddleware<TokenAuthMiddleware>();
app.UseOcelot().Wait();//使用Ocelot中间件
app.Run();