Remove superfluous UseDeveloperExceptionPage() and AddOptions() calls
This commit is contained in:
parent
e2d8590a26
commit
917764273b
@ -15,7 +15,6 @@ builder.Services.AddControllers()
|
||||
|
||||
builder.Services.AddSwaggerGen(options =>
|
||||
{
|
||||
//options.DescribeAllEnumsAsStrings();
|
||||
options.SwaggerDoc("v1", new OpenApiInfo
|
||||
{
|
||||
Title = "Shopping Aggregator for Mobile Clients",
|
||||
|
@ -1,6 +1,5 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Logging.AddConsole();
|
||||
builder.Services.AddHealthChecks()
|
||||
.AddCheck("self", () => HealthCheckResult.Healthy())
|
||||
.AddUrlGroup(new Uri(builder.Configuration["CatalogUrlHC"]), name: "catalogapi-check", tags: new string[] { "catalogapi" })
|
||||
@ -13,11 +12,7 @@ builder.Services.AddCustomMvc(builder.Configuration)
|
||||
.AddApplicationServices()
|
||||
.AddGrpcServices();
|
||||
var app = builder.Build();
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
else
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
}
|
||||
@ -82,7 +77,6 @@ public static class ServiceCollectionExtensions
|
||||
}
|
||||
public static IServiceCollection AddCustomMvc(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddOptions();
|
||||
services.Configure<UrlsConfig>(configuration.GetSection("urls"));
|
||||
|
||||
services.AddControllers()
|
||||
|
@ -40,27 +40,20 @@ builder.Services
|
||||
|
||||
var services = builder.Services;
|
||||
|
||||
services.AddMediatR(cfg =>
|
||||
{
|
||||
services.AddMediatR(cfg =>
|
||||
{
|
||||
cfg.RegisterServicesFromAssemblyContaining(typeof(Program));
|
||||
|
||||
cfg.AddOpenBehavior(typeof(LoggingBehavior<,>));
|
||||
cfg.AddOpenBehavior(typeof(ValidatorBehavior<,>));
|
||||
cfg.AddOpenBehavior(typeof(TransactionBehavior<,>));
|
||||
});
|
||||
});
|
||||
|
||||
// Register the command validators for the validator behavior (validators based on FluentValidation library)
|
||||
services.AddSingleton<IValidator<CancelOrderCommand>, CancelOrderCommandValidator>();
|
||||
services.AddSingleton<IValidator<CreateOrderCommand>, CreateOrderCommandValidator>();
|
||||
services.AddSingleton<IValidator<IdentifiedCommand<CreateOrderCommand, bool>>, IdentifiedCommandValidator>();
|
||||
services.AddSingleton<IValidator<ShipOrderCommand>, ShipOrderCommandValidator>();
|
||||
|
||||
/*
|
||||
// Build the MediatR pipeline
|
||||
services.AddSingleton(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>));
|
||||
services.AddSingleton(typeof(IPipelineBehavior<,>), typeof(ValidatorBehavior<,>));
|
||||
services.AddSingleton(typeof(IPipelineBehavior<,>), typeof(TransactionBehavior<,>));
|
||||
*/
|
||||
// Register the command validators for the validator behavior (validators based on FluentValidation library)
|
||||
services.AddSingleton<IValidator<CancelOrderCommand>, CancelOrderCommandValidator>();
|
||||
services.AddSingleton<IValidator<CreateOrderCommand>, CreateOrderCommandValidator>();
|
||||
services.AddSingleton<IValidator<IdentifiedCommand<CreateOrderCommand, bool>>, IdentifiedCommandValidator>();
|
||||
services.AddSingleton<IValidator<ShipOrderCommand>, ShipOrderCommandValidator>();
|
||||
|
||||
var queriesConnectionString = builder.Configuration["ConnectionString"];
|
||||
|
||||
@ -78,19 +71,17 @@ services.AddSingleton<IIntegrationEventHandler<OrderStockRejectedIntegrationEven
|
||||
services.AddSingleton<IIntegrationEventHandler<UserCheckoutAcceptedIntegrationEvent>, UserCheckoutAcceptedIntegrationEventHandler>();
|
||||
|
||||
var app = builder.Build();
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
else
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
}
|
||||
|
||||
var pathBase = app.Configuration["PATH_BASE"];
|
||||
if (!string.IsNullOrEmpty(pathBase))
|
||||
{
|
||||
app.UsePathBase(pathBase);
|
||||
}
|
||||
|
||||
app.UseSwagger().UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint($"{(!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty)}/swagger/v1/swagger.json", "Ordering.API V1");
|
||||
@ -336,7 +327,6 @@ static class CustomExtensionsMethods
|
||||
|
||||
public static IServiceCollection AddCustomConfiguration(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddOptions();
|
||||
services.Configure<OrderingSettings>(configuration);
|
||||
services.Configure<ApiBehaviorOptions>(options =>
|
||||
{
|
||||
|
@ -9,18 +9,14 @@ builder.Configuration.AddJsonFile($"appsettings.{builder.Environment.Environment
|
||||
builder.Configuration.AddEnvironmentVariables();
|
||||
builder.Services.AddCustomHealthCheck(builder.Configuration)
|
||||
.Configure<BackgroundTaskSettings>(builder.Configuration)
|
||||
.AddOptions()
|
||||
.AddHostedService<GracePeriodManagerService>()
|
||||
.AddEventBus(builder.Configuration);
|
||||
var app = builder.Build();
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
else
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
}
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.MapHealthChecks("/hc", new HealthCheckOptions()
|
||||
|
@ -85,19 +85,17 @@ builder.Services.AddSingleton<IIntegrationEventHandler<OrderStatusChangedToStock
|
||||
builder.Services.AddSingleton<IIntegrationEventHandler<OrderStatusChangedToSubmittedIntegrationEvent>, OrderStatusChangedToSubmittedIntegrationEventHandler>();
|
||||
|
||||
var app = builder.Build();
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
else
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
}
|
||||
|
||||
var pathBase = builder.Configuration["PATH_BASE"];
|
||||
if (!string.IsNullOrEmpty(pathBase))
|
||||
{
|
||||
app.UsePathBase(pathBase);
|
||||
}
|
||||
|
||||
app.UseRouting();
|
||||
app.UseCors("CorsPolicy");
|
||||
app.UseAuthentication();
|
||||
|
@ -57,19 +57,17 @@ else
|
||||
}
|
||||
RegisterEventBus(builder.Services);
|
||||
var app = builder.Build();
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
else
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
}
|
||||
|
||||
var pathBase = app.Configuration["PATH_BASE"];
|
||||
if (!string.IsNullOrEmpty(pathBase))
|
||||
{
|
||||
app.UsePathBase(pathBase);
|
||||
}
|
||||
|
||||
ConfigureEventBus(app);
|
||||
|
||||
app.UseRouting();
|
||||
|
@ -12,11 +12,7 @@ builder.WebHost.CaptureStartupErrors(false);
|
||||
var app = builder.Build();
|
||||
|
||||
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove("sub");
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
else
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Error");
|
||||
}
|
||||
@ -72,8 +68,7 @@ static void AddHealthChecks(WebApplicationBuilder builder)
|
||||
|
||||
static void AddCustomMvc(WebApplicationBuilder builder)
|
||||
{
|
||||
builder.Services.AddOptions()
|
||||
.Configure<AppSettings>(builder.Configuration)
|
||||
builder.Services.Configure<AppSettings>(builder.Configuration)
|
||||
.AddSession()
|
||||
.AddDistributedMemoryCache();
|
||||
|
||||
|
@ -40,11 +40,6 @@ builder.Logging.AddAzureWebAppDiagnostics();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
// Here we add Angular default Anti-forgery cookie name on first load. https://angular.io/guide/http#security-xsrf-protection
|
||||
// This cookie will be read by Angular app and its value will be sent back to the application as the header configured in .AddAntiforgery()
|
||||
var antiForgery = app.Services.GetRequiredService<IAntiforgery>();
|
||||
|
@ -12,7 +12,6 @@ builder.WebHost.CaptureStartupErrors(false);
|
||||
builder.Services.AddApplicationInsightsTelemetry(builder.Configuration);
|
||||
builder.Services.AddApplicationInsightsKubernetesEnricher();
|
||||
builder.Services.AddMvc();
|
||||
builder.Services.AddOptions();
|
||||
builder.Services.AddHealthChecks()
|
||||
.AddCheck("self", () => HealthCheckResult.Healthy());
|
||||
builder.Services
|
||||
@ -21,11 +20,7 @@ builder.Services
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
else
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace WebhookClient;
|
||||
namespace WebhookClient;
|
||||
|
||||
public class Startup
|
||||
{
|
||||
@ -36,15 +36,12 @@ public class Startup
|
||||
app.UsePathBase(pathBase);
|
||||
}
|
||||
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
else
|
||||
if (!env.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
}
|
||||
|
||||
app.Map("/check", capp =>
|
||||
{
|
||||
capp.Run(async (context) =>
|
||||
@ -97,7 +94,6 @@ static class ServiceExtensions
|
||||
{
|
||||
public static IServiceCollection AddConfiguration(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddOptions();
|
||||
services.Configure<Settings>(configuration);
|
||||
return services;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user