2023-08-06 15:56:08 +01:00
|
|
|
using NLog.Extensions.Logging;
|
2023-08-06 15:57:23 +01:00
|
|
|
using OliverBooth.Data;
|
2023-08-06 15:56:08 +01:00
|
|
|
using OliverBooth.Services;
|
|
|
|
using X10D.Hosting.DependencyInjection;
|
|
|
|
|
2023-08-04 00:38:44 +01:00
|
|
|
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
2023-08-06 15:57:23 +01:00
|
|
|
builder.Configuration.AddTomlFile("data/config.toml", true, true);
|
2023-05-26 19:05:44 +01:00
|
|
|
|
2023-08-06 15:56:08 +01:00
|
|
|
builder.Logging.ClearProviders();
|
|
|
|
builder.Logging.AddNLog();
|
|
|
|
builder.Services.AddHostedSingleton<LoggingService>();
|
|
|
|
|
2023-08-06 15:57:23 +01:00
|
|
|
builder.Services.AddDbContextFactory<BlogContext>();
|
|
|
|
builder.Services.AddDbContextFactory<WebContext>();
|
2023-08-06 15:55:12 +01:00
|
|
|
builder.Services.AddRazorPages().AddRazorRuntimeCompilation();
|
2023-08-05 21:01:47 +01:00
|
|
|
builder.Services.AddControllersWithViews();
|
2023-08-04 00:38:44 +01:00
|
|
|
builder.Services.AddRouting(options => options.LowercaseUrls = true);
|
2023-05-26 19:05:44 +01:00
|
|
|
|
2023-08-04 00:38:44 +01:00
|
|
|
WebApplication app = builder.Build();
|
2023-05-26 19:05:44 +01:00
|
|
|
|
|
|
|
if (!app.Environment.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.UseHsts();
|
|
|
|
}
|
|
|
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseStaticFiles();
|
|
|
|
app.UseRouting();
|
|
|
|
app.UseAuthorization();
|
2023-08-05 20:58:03 +01:00
|
|
|
|
2023-08-05 21:01:47 +01:00
|
|
|
app.MapControllers();
|
2023-08-06 02:27:16 +01:00
|
|
|
app.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
|
2023-05-26 19:05:44 +01:00
|
|
|
app.MapRazorPages();
|
|
|
|
|
|
|
|
app.Run();
|