Files
TakeoutSaaS.AdminApi/src/Gateway/TakeoutSaaS.ApiGateway/Program.cs

54 lines
1.4 KiB
C#

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();