49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
/* This software is licensed by the MIT License, see LICENSE file */
|
|
/* Copyright © 2024-2025 Gregory Lirent */
|
|
|
|
using Microsoft.Extensions.Options;
|
|
using System.Runtime.Versioning;
|
|
using WebmrAPI.Configuration;
|
|
using WebmrAPI.Services;
|
|
|
|
[assembly: SupportedOSPlatform("windows")]
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services.AddWindowsService();
|
|
builder.Services.Configure<AppSettings>(builder.Configuration);
|
|
builder.Services.AddLogging(config =>
|
|
{
|
|
config.AddConsole();
|
|
config.AddDebug();
|
|
});
|
|
|
|
builder.Services.AddRouting(options =>
|
|
{
|
|
options.LowercaseUrls = true;
|
|
options.LowercaseQueryStrings = true;
|
|
});
|
|
|
|
builder.Services.AddControllers();
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
builder.Services.AddSingleton<ProcessMonitor>();
|
|
builder.Services.AddHostedService(sp => sp.GetRequiredService<ProcessMonitor>());
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------------- \\
|
|
|
|
var app = builder.Build();
|
|
var settings = app.Services.GetRequiredService<IOptions<AppSettings>>().Value;
|
|
|
|
app.Urls.Add(settings.WebServer.Url);
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.MapControllers();
|
|
app.Run();
|