✨ Gateway config serving
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("config")]
|
||||||
|
public class ConfigurationController(IConfiguration configuration) : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Get() => Ok(configuration.GetSection("Client").Get<Dictionary<string, object>>());
|
||||||
|
|
||||||
|
[HttpGet("site")]
|
||||||
|
public IActionResult GetSiteUrl() => Ok(configuration["SiteUrl"]);
|
||||||
|
}
|
@@ -87,7 +87,7 @@ var swaggerRoutes = serviceNames.Select(serviceName => new RouteConfig
|
|||||||
RouteId = $"{serviceName}-swagger",
|
RouteId = $"{serviceName}-swagger",
|
||||||
ClusterId = serviceName,
|
ClusterId = serviceName,
|
||||||
Match = new RouteMatch { Path = $"/swagger/{serviceName}/{{**catch-all}}" },
|
Match = new RouteMatch { Path = $"/swagger/{serviceName}/{{**catch-all}}" },
|
||||||
Transforms =
|
Transforms =
|
||||||
[
|
[
|
||||||
new Dictionary<string, string> { { "PathRemovePrefix", $"/swagger/{serviceName}" } },
|
new Dictionary<string, string> { { "PathRemovePrefix", $"/swagger/{serviceName}" } },
|
||||||
new Dictionary<string, string> { { "PathPrefix", "/swagger" } }
|
new Dictionary<string, string> { { "PathPrefix", "/swagger" } }
|
||||||
@@ -106,9 +106,11 @@ var clusters = serviceNames.Select(serviceName => new ClusterConfig
|
|||||||
}).ToArray();
|
}).ToArray();
|
||||||
|
|
||||||
builder.Services
|
builder.Services
|
||||||
.AddReverseProxy()
|
.AddReverseProxy()
|
||||||
.LoadFromMemory(routes, clusters)
|
.LoadFromMemory(routes, clusters)
|
||||||
.AddServiceDiscoveryDestinationResolver();
|
.AddServiceDiscoveryDestinationResolver();
|
||||||
|
|
||||||
|
builder.Services.AddControllers();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
@@ -118,4 +120,6 @@ app.UseRateLimiter();
|
|||||||
|
|
||||||
app.MapReverseProxy().RequireRateLimiting("fixed");
|
app.MapReverseProxy().RequireRateLimiting("fixed");
|
||||||
|
|
||||||
|
app.MapControllers();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
@@ -5,5 +5,9 @@
|
|||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*",
|
||||||
|
"SiteUrl": "http://localhost:3000",
|
||||||
|
"Client": {
|
||||||
|
"SomeSetting": "SomeValue"
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user