✨ Customizable gateway endpoints
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.RateLimiting;
|
||||
using DysonNetwork.Gateway.Configuration;
|
||||
using DysonNetwork.Gateway.Health;
|
||||
using DysonNetwork.Shared.Networking;
|
||||
using Yarp.ReverseProxy.Configuration;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.Extensions.Options;
|
||||
using NodaTime;
|
||||
using NodaTime.Serialization.SystemTextJson;
|
||||
|
||||
@@ -17,6 +19,10 @@ builder.ConfigureAppKestrel(builder.Configuration, maxRequestBodySize: long.MaxV
|
||||
builder.Services.AddSingleton<GatewayReadinessStore>();
|
||||
builder.Services.AddHostedService<GatewayHealthAggregator>();
|
||||
|
||||
// Add configuration options for gateway endpoints
|
||||
builder.Services.Configure<DysonNetwork.Gateway.Configuration.GatewayEndpointsOptions>(
|
||||
builder.Configuration.GetSection(DysonNetwork.Gateway.Configuration.GatewayEndpointsOptions.SectionName));
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddDefaultPolicy(policy =>
|
||||
@@ -170,6 +176,15 @@ builder.Services.AddControllers().AddJsonOptions(options =>
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Initialize GatewayConstant with configuration values
|
||||
var gatewayEndpointsOptions = app.Services
|
||||
.GetRequiredService<IOptions<GatewayEndpointsOptions>>().Value;
|
||||
GatewayConstant.InitializeFromConfiguration(gatewayEndpointsOptions);
|
||||
|
||||
// Reinitialize the readiness store with configured service names
|
||||
var readinessStore = app.Services.GetRequiredService<GatewayReadinessStore>();
|
||||
readinessStore.ReinitializeServices(GatewayConstant.ServiceNames);
|
||||
|
||||
var forwardedHeadersOptions = new ForwardedHeadersOptions
|
||||
{
|
||||
ForwardedHeaders = ForwardedHeaders.All
|
||||
@@ -186,4 +201,4 @@ app.MapReverseProxy().RequireRateLimiting("fixed");
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
app.Run();
|
||||
Reference in New Issue
Block a user