chore: 初始化项目基础文件
This commit is contained in:
53
src/Gateway/TakeoutSaaS.ApiGateway/Program.cs
Normal file
53
src/Gateway/TakeoutSaaS.ApiGateway/Program.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddReverseProxy()
|
||||
.LoadFromMemory(new()
|
||||
{
|
||||
Clusters =
|
||||
{
|
||||
["admin"] = new()
|
||||
{
|
||||
Destinations = { ["d1"] = new() { Address = "http://localhost:5001/" } }
|
||||
},
|
||||
["mini"] = new()
|
||||
{
|
||||
Destinations = { ["d1"] = new() { Address = "http://localhost:5002/" } }
|
||||
},
|
||||
["user"] = new()
|
||||
{
|
||||
Destinations = { ["d1"] = new() { Address = "http://localhost:5003/" } }
|
||||
}
|
||||
},
|
||||
Routes =
|
||||
{
|
||||
new()
|
||||
{
|
||||
RouteId = "admin-route",
|
||||
ClusterId = "admin",
|
||||
Match = new() { Path = "/api/admin/{**catch-all}" }
|
||||
},
|
||||
new()
|
||||
{
|
||||
RouteId = "mini-route",
|
||||
ClusterId = "mini",
|
||||
Match = new() { Path = "/api/mini/{**catch-all}" }
|
||||
},
|
||||
new()
|
||||
{
|
||||
RouteId = "user-route",
|
||||
ClusterId = "user",
|
||||
Match = new() { Path = "/api/user/{**catch-all}" }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.MapReverseProxy();
|
||||
|
||||
app.Run();
|
||||
|
||||
Reference in New Issue
Block a user