This repository has been archived on 2023-06-01. You can view files and clone it, but cannot push or open issues or pull requests.
discord-bot-shtik/Program.cs

54 lines
1.4 KiB
C#
Raw Normal View History

2024-04-08 15:00:55 -04:00
using Microsoft.AspNetCore.Mvc.Razor;
2023-07-04 20:40:37 -04:00
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Mvc.NewtonsoftJson;
2023-07-04 20:40:37 -04:00
using vassago.Models;
#pragma warning disable CA2254
2023-07-03 12:51:23 -04:00
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
builder.Services.AddSingleton<IHostedService, vassago.ConsoleService>();
builder.Services.AddDbContext<ChattingContext>();
builder.Services.AddControllers().AddNewtonsoftJson();
builder.Services.AddProblemDetails();
2024-04-08 15:00:55 -04:00
builder.Services.Configure<RazorViewEngineOptions>(o => {
o.ViewLocationFormats.Clear();
o.ViewLocationFormats.Add("/WebInterface/Views/{1}/{0}" + RazorViewEngine.ViewExtension);
o.ViewLocationFormats.Add("/WebInterface/Views/Shared/{0}" + RazorViewEngine.ViewExtension);
});
2024-06-02 18:37:04 -04:00
builder.Services.AddSwaggerGen();
2023-07-03 12:51:23 -04:00
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
2024-06-02 18:37:04 -04:00
app.UseSwagger();
app.UseSwaggerUI(c =>
{
2024-06-09 17:37:09 -04:00
c.SwaggerEndpoint("/swagger/v1/swagger.json", "api");
2024-06-02 18:37:04 -04:00
});
2024-04-08 15:00:55 -04:00
app.UseExceptionHandler();
app.UseStatusCodePages();
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
2023-07-03 12:51:23 -04:00
app.Run();