48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Logging.Console;
|
|
using Moonlight.Shared.Http;
|
|
using Moonlight.Api.Helpers;
|
|
using Moonlight.Api.Implementations;
|
|
using Moonlight.Api.Interfaces;
|
|
using Moonlight.Api.Services;
|
|
|
|
namespace Moonlight.Api.Startup;
|
|
|
|
public partial class Startup
|
|
{
|
|
private static void AddBase(WebApplicationBuilder builder)
|
|
{
|
|
builder.Services.AddControllers().AddJsonOptions(options =>
|
|
{
|
|
options.JsonSerializerOptions.TypeInfoResolverChain.Add(SerializationContext.Default);
|
|
});
|
|
|
|
builder.Logging.ClearProviders();
|
|
builder.Logging.AddConsole(options => { options.FormatterName = nameof(AppConsoleFormatter); });
|
|
builder.Logging.AddConsoleFormatter<AppConsoleFormatter, ConsoleFormatterOptions>();
|
|
|
|
builder.Services.AddSingleton<ApplicationService>();
|
|
builder.Services.AddHostedService(sp => sp.GetRequiredService<ApplicationService>());
|
|
|
|
builder.Services.AddSingleton<DiagnoseService>();
|
|
|
|
builder.Services.AddSingleton<IDiagnoseProvider, UpdateDiagnoseProvider>();
|
|
|
|
builder.Services.AddMemoryCache();
|
|
builder.Services.AddOptions<SessionOptions>().BindConfiguration("Moonlight:Session");
|
|
}
|
|
|
|
private static void UseBase(WebApplication application)
|
|
{
|
|
application.UseRouting();
|
|
}
|
|
|
|
private static void MapBase(WebApplication application)
|
|
{
|
|
application.MapControllers();
|
|
|
|
application.MapFallbackToFile("index.html");
|
|
}
|
|
} |