search and ai stabilization work, localization stablized.
This commit is contained in:
@@ -15,6 +15,7 @@ using StellaOps.Auth.ServerIntegration;
|
||||
using StellaOps.Auth.ServerIntegration.Tenancy;
|
||||
using StellaOps.Configuration;
|
||||
using StellaOps.Determinism;
|
||||
using StellaOps.Localization;
|
||||
using StellaOps.Policy.Deltas;
|
||||
using StellaOps.Policy.Engine.Gates;
|
||||
using StellaOps.Policy.Gateway.Clients;
|
||||
@@ -32,6 +33,7 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
using StellaOps.Router.AspNet;
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@@ -304,6 +306,34 @@ builder.Services.AddHttpClient<IPolicyEngineClient, PolicyEngineClient>((service
|
||||
})
|
||||
.AddPolicyHandler(static (provider, _) => CreatePolicyEngineRetryPolicy(provider));
|
||||
|
||||
builder.Services.AddStellaOpsLocalization(builder.Configuration, options =>
|
||||
{
|
||||
options.DefaultLocale = string.IsNullOrWhiteSpace(options.DefaultLocale) ? "en-US" : options.DefaultLocale;
|
||||
if (options.SupportedLocales.Count == 0)
|
||||
{
|
||||
options.SupportedLocales.Add("en-US");
|
||||
}
|
||||
|
||||
if (!options.SupportedLocales.Contains("de-DE", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
options.SupportedLocales.Add("de-DE");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(options.RemoteBundleUrl))
|
||||
{
|
||||
var platformUrl = builder.Configuration["STELLAOPS_PLATFORM_URL"] ?? builder.Configuration["Platform:BaseUrl"];
|
||||
if (!string.IsNullOrWhiteSpace(platformUrl))
|
||||
{
|
||||
options.RemoteBundleUrl = platformUrl;
|
||||
}
|
||||
}
|
||||
|
||||
options.EnableRemoteBundles =
|
||||
options.EnableRemoteBundles || !string.IsNullOrWhiteSpace(options.RemoteBundleUrl);
|
||||
});
|
||||
builder.Services.AddTranslationBundle(System.Reflection.Assembly.GetExecutingAssembly());
|
||||
builder.Services.AddRemoteTranslationBundles();
|
||||
|
||||
// Stella Router integration
|
||||
var routerEnabled = builder.Services.AddRouterMicroservice(
|
||||
builder.Configuration,
|
||||
@@ -317,20 +347,23 @@ app.LogStellaOpsLocalHostname("policy-gateway");
|
||||
app.UseExceptionHandler(static appBuilder => appBuilder.Run(async context =>
|
||||
{
|
||||
context.Response.StatusCode = StatusCodes.Status500InternalServerError;
|
||||
await context.Response.WriteAsJsonAsync(new { error = "Unexpected gateway error." });
|
||||
await context.Response.WriteAsJsonAsync(new { error = _t("policy.error.unexpected_gateway_error") });
|
||||
}));
|
||||
|
||||
app.UseStatusCodePages();
|
||||
|
||||
app.UseStellaOpsCors();
|
||||
app.UseStellaOpsLocalization();
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
app.UseStellaOpsTenantMiddleware();
|
||||
app.TryUseStellaRouter(routerEnabled);
|
||||
|
||||
await app.LoadTranslationsAsync();
|
||||
|
||||
app.MapHealthChecks("/healthz");
|
||||
|
||||
app.MapGet("/readyz", () => Results.Ok(new { status = "ready" }))
|
||||
app.MapGet("/readyz", () => Results.Ok(new { status = _t("policy.status.ready") }))
|
||||
.WithName("Readiness")
|
||||
.AllowAnonymous();
|
||||
|
||||
@@ -388,7 +421,7 @@ policyPacks.MapPost(string.Empty, async Task<IResult> (
|
||||
{
|
||||
return Results.BadRequest(new ProblemDetails
|
||||
{
|
||||
Title = "Request body required.",
|
||||
Title = _t("common.error.body_required"),
|
||||
Status = StatusCodes.Status400BadRequest
|
||||
});
|
||||
}
|
||||
@@ -420,7 +453,7 @@ policyPacks.MapPost("/{packId}/revisions", async Task<IResult> (
|
||||
{
|
||||
return Results.BadRequest(new ProblemDetails
|
||||
{
|
||||
Title = "packId is required.",
|
||||
Title = _t("policy.validation.pack_id_required"),
|
||||
Status = StatusCodes.Status400BadRequest
|
||||
});
|
||||
}
|
||||
@@ -429,7 +462,7 @@ policyPacks.MapPost("/{packId}/revisions", async Task<IResult> (
|
||||
{
|
||||
return Results.BadRequest(new ProblemDetails
|
||||
{
|
||||
Title = "Request body required.",
|
||||
Title = _t("common.error.body_required"),
|
||||
Status = StatusCodes.Status400BadRequest
|
||||
});
|
||||
}
|
||||
@@ -464,7 +497,7 @@ policyPacks.MapPost("/{packId}/revisions/{version:int}:activate", async Task<IRe
|
||||
{
|
||||
return Results.BadRequest(new ProblemDetails
|
||||
{
|
||||
Title = "packId is required.",
|
||||
Title = _t("policy.validation.pack_id_required"),
|
||||
Status = StatusCodes.Status400BadRequest
|
||||
});
|
||||
}
|
||||
@@ -473,7 +506,7 @@ policyPacks.MapPost("/{packId}/revisions/{version:int}:activate", async Task<IRe
|
||||
{
|
||||
return Results.BadRequest(new ProblemDetails
|
||||
{
|
||||
Title = "Request body required.",
|
||||
Title = _t("common.error.body_required"),
|
||||
Status = StatusCodes.Status400BadRequest
|
||||
});
|
||||
}
|
||||
@@ -520,7 +553,7 @@ cvss.MapPost("/receipts", async Task<IResult>(
|
||||
{
|
||||
return Results.BadRequest(new ProblemDetails
|
||||
{
|
||||
Title = "Request body required.",
|
||||
Title = _t("common.error.body_required"),
|
||||
Status = StatusCodes.Status400BadRequest
|
||||
});
|
||||
}
|
||||
@@ -574,7 +607,7 @@ cvss.MapPut("/receipts/{receiptId}/amend", async Task<IResult>(
|
||||
{
|
||||
return Results.BadRequest(new ProblemDetails
|
||||
{
|
||||
Title = "Request body required.",
|
||||
Title = _t("common.error.body_required"),
|
||||
Status = StatusCodes.Status400BadRequest
|
||||
});
|
||||
}
|
||||
@@ -668,7 +701,7 @@ app.MapAdvisorySourcePolicyEndpoints();
|
||||
app.MapToolLatticeEndpoints();
|
||||
|
||||
app.TryRefreshStellaRouterEndpoints(routerEnabled);
|
||||
app.Run();
|
||||
await app.RunAsync().ConfigureAwait(false);
|
||||
|
||||
static IAsyncPolicy<HttpResponseMessage> CreateAuthorityRetryPolicy(IServiceProvider provider)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user