chore: 同步当前开发内容
This commit is contained in:
@@ -1,49 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Yarp.ReverseProxy.Configuration;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddReverseProxy()
|
||||
.LoadFromMemory(new()
|
||||
var routes = new[]
|
||||
{
|
||||
new RouteConfig
|
||||
{
|
||||
Clusters =
|
||||
RouteId = "admin-route",
|
||||
ClusterId = "admin",
|
||||
Match = new() { Path = "/api/admin/{**catch-all}" }
|
||||
},
|
||||
new RouteConfig
|
||||
{
|
||||
RouteId = "mini-route",
|
||||
ClusterId = "mini",
|
||||
Match = new() { Path = "/api/mini/{**catch-all}" }
|
||||
},
|
||||
new RouteConfig
|
||||
{
|
||||
RouteId = "user-route",
|
||||
ClusterId = "user",
|
||||
Match = new() { Path = "/api/user/{**catch-all}" }
|
||||
}
|
||||
};
|
||||
|
||||
var clusters = new[]
|
||||
{
|
||||
new ClusterConfig
|
||||
{
|
||||
ClusterId = "admin",
|
||||
Destinations = new Dictionary<string, DestinationConfig>
|
||||
{
|
||||
["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}" }
|
||||
}
|
||||
["d1"] = new() { Address = "http://localhost:5001/" }
|
||||
}
|
||||
});
|
||||
},
|
||||
new ClusterConfig
|
||||
{
|
||||
ClusterId = "mini",
|
||||
Destinations = new Dictionary<string, DestinationConfig>
|
||||
{
|
||||
["d1"] = new() { Address = "http://localhost:5002/" }
|
||||
}
|
||||
},
|
||||
new ClusterConfig
|
||||
{
|
||||
ClusterId = "user",
|
||||
Destinations = new Dictionary<string, DestinationConfig>
|
||||
{
|
||||
["d1"] = new() { Address = "http://localhost:5003/" }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
builder.Services.AddReverseProxy()
|
||||
.LoadFromMemory(routes, clusters);
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user