Refactor Kestrel config and add exception middleware
Replaced "UseKestrelConfig" with "UseCustomKestrelEndpoints" and renamed the "Kestrel" section to "ServerConfig" in both Program.cs and appsettings.json. Updated Kestrel server configuration to use the new section. Added ExceptionHandlingMiddleware to the pipeline for global exception handling.
This commit is contained in:
@@ -3,6 +3,7 @@ using EnvelopeGenerator.Application;
|
|||||||
using EnvelopeGenerator.Infrastructure;
|
using EnvelopeGenerator.Infrastructure;
|
||||||
using EnvelopeGenerator.ServiceHost;
|
using EnvelopeGenerator.ServiceHost;
|
||||||
using EnvelopeGenerator.ServiceHost.Extensions;
|
using EnvelopeGenerator.ServiceHost.Extensions;
|
||||||
|
using EnvelopeGenerator.ServiceHost.Middleware;
|
||||||
using Microsoft.AspNetCore.Localization;
|
using Microsoft.AspNetCore.Localization;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
@@ -15,12 +16,12 @@ if (builder.Configuration.GetValue<bool>("UseWindowsService"))
|
|||||||
builder.Host.UseWindowsService();
|
builder.Host.UseWindowsService();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (builder.Configuration.GetValue<bool>("UseKestrelConfig"))
|
if (builder.Configuration.GetValue<bool>("UseCustomKestrelEndpoints"))
|
||||||
{
|
{
|
||||||
builder.WebHost.ConfigureKestrel((context, serverOptions) =>
|
builder.WebHost.ConfigureKestrel((context, serverOptions) =>
|
||||||
{
|
{
|
||||||
var kestrelSection = context.Configuration.GetSection("Kestrel");
|
var serverConfigSection = context.Configuration.GetSection("ServerConfig");
|
||||||
serverOptions.Configure(kestrelSection);
|
serverOptions.Configure(serverConfigSection);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -65,6 +66,8 @@ builder.Services.AddSwaggerGen();
|
|||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
app.UseMiddleware<ExceptionHandlingMiddleware>();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
"Default": "Server=SDD-VMP04-SQL17\\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;"
|
"Default": "Server=SDD-VMP04-SQL17\\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;"
|
||||||
},
|
},
|
||||||
"UseWindowsService": false,
|
"UseWindowsService": false,
|
||||||
"UseKestrelConfig": false,
|
"UseCustomKestrelEndpoints": false,
|
||||||
"Kestrel": {
|
"ServerConfig": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://localhost:1111"
|
"Url": "http://localhost:1111"
|
||||||
|
|||||||
Reference in New Issue
Block a user