More defaults
This commit is contained in:
parent
9af6d6342d
commit
00fc3d8a65
@ -2,9 +2,7 @@
|
|||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
builder.Configuration.AddKeyVault();
|
builder.AddServiceDefaults();
|
||||||
|
|
||||||
builder.Services.AddApplicationInsights(builder.Configuration);
|
|
||||||
|
|
||||||
builder.Services.AddGrpc(options =>
|
builder.Services.AddGrpc(options =>
|
||||||
{
|
{
|
||||||
@ -17,24 +15,12 @@ builder.Services.AddControllers(options =>
|
|||||||
options.Filters.Add(typeof(ValidateModelStateFilter));
|
options.Filters.Add(typeof(ValidateModelStateFilter));
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddDefaultOpenApi(builder.Configuration);
|
|
||||||
|
|
||||||
builder.Services.AddDefaultAuthentication(builder.Configuration);
|
|
||||||
|
|
||||||
builder.Services.AddDefaultHealthChecks(builder.Configuration);
|
|
||||||
|
|
||||||
builder.Host.UseDefaultSerilog(builder.Configuration, AppName);
|
|
||||||
|
|
||||||
builder.WebHost.UseDefaultPorts(builder.Configuration);
|
|
||||||
|
|
||||||
builder.WebHost.UseFailing(options =>
|
builder.WebHost.UseFailing(options =>
|
||||||
{
|
{
|
||||||
options.ConfigPath = "/Failing";
|
options.ConfigPath = "/Failing";
|
||||||
options.NotFilteredPaths.AddRange(new[] { "/hc", "/liveness" });
|
options.NotFilteredPaths.AddRange(new[] { "/hc", "/liveness" });
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddEventBus(builder.Configuration);
|
|
||||||
|
|
||||||
builder.Services.Configure<BasketSettings>(builder.Configuration);
|
builder.Services.Configure<BasketSettings>(builder.Configuration);
|
||||||
|
|
||||||
builder.Services.AddRedis();
|
builder.Services.AddRedis();
|
||||||
@ -49,24 +35,11 @@ var app = builder.Build();
|
|||||||
|
|
||||||
app.MapGet("hello", () => "hello");
|
app.MapGet("hello", () => "hello");
|
||||||
|
|
||||||
if (!app.Environment.IsDevelopment())
|
app.UseServiceDefaults();
|
||||||
{
|
|
||||||
app.UseExceptionHandler("/Home/Error");
|
|
||||||
}
|
|
||||||
|
|
||||||
var pathBase = app.Configuration["PATH_BASE"];
|
|
||||||
if (!string.IsNullOrEmpty(pathBase))
|
|
||||||
{
|
|
||||||
app.UsePathBase(pathBase);
|
|
||||||
}
|
|
||||||
|
|
||||||
app.UseDefaultOpenApi(builder.Configuration);
|
|
||||||
|
|
||||||
app.MapGrpcService<BasketService>();
|
app.MapGrpcService<BasketService>();
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
app.MapDefaultHealthChecks();
|
|
||||||
|
|
||||||
var eventBus = app.Services.GetRequiredService<IEventBus>();
|
var eventBus = app.Services.GetRequiredService<IEventBus>();
|
||||||
|
|
||||||
eventBus.Subscribe<ProductPriceChangedIntegrationEvent, ProductPriceChangedIntegrationEventHandler>();
|
eventBus.Subscribe<ProductPriceChangedIntegrationEvent, ProductPriceChangedIntegrationEventHandler>();
|
||||||
|
@ -58,6 +58,11 @@ public static class CommonExtensions
|
|||||||
|
|
||||||
public static WebApplication UseServiceDefaults(this WebApplication app)
|
public static WebApplication UseServiceDefaults(this WebApplication app)
|
||||||
{
|
{
|
||||||
|
if (!app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseExceptionHandler("/Home/Error");
|
||||||
|
}
|
||||||
|
|
||||||
var pathBase = app.Configuration["PATH_BASE"];
|
var pathBase = app.Configuration["PATH_BASE"];
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(pathBase))
|
if (!string.IsNullOrEmpty(pathBase))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user