68 lines
1.6 KiB
C#
68 lines
1.6 KiB
C#
using HackerNet.Infrastructure.AspNet;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
//ServiceCollectionExtensions.AddHackerNetServices(builder.Services);
|
|
builder.Services
|
|
//.AddHackerNetServicesMemory()
|
|
.AddHackerNetServicesEntityFramework()
|
|
.AddControllersWithViews(o =>
|
|
{
|
|
//o.Filters.Add<CustomExceptionFilter>();
|
|
});
|
|
|
|
var app = builder.Build();
|
|
|
|
app.MigrateDatabase();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Home/Error");
|
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.Use(async (ctx, next) =>
|
|
{
|
|
var logger = ctx.RequestServices.GetRequiredService<ILogger<Program>>();
|
|
logger.LogDebug(">>>>>>>>>>>>>> Début requête");
|
|
try
|
|
{
|
|
await next();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// Envoi app insights ou autre
|
|
logger.LogError(e.Message);
|
|
|
|
throw e;
|
|
}
|
|
logger.LogDebug("<<<<<<<<<<<<<< Fin requête");
|
|
});
|
|
|
|
app.Use(async (ctx, next) =>
|
|
{
|
|
var logger = ctx.RequestServices.GetRequiredService<ILogger<Program>>();
|
|
logger.LogDebug(">>>>>>>>>>>>>> Début requête 2");
|
|
await next();
|
|
logger.LogDebug("<<<<<<<<<<<<<< Fin requête 2");
|
|
});
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseStaticFiles();
|
|
|
|
app.UseStatusCodePagesWithRedirects("/{0}");
|
|
|
|
app.UseRouting();
|
|
|
|
// app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllerRoute(
|
|
name: "default",
|
|
pattern: "{controller=Links}/{action=Index}/{id?}");
|
|
|
|
app.Run();
|