stitch_something/StitchATon/Program.cs

50 lines
1.4 KiB
C#

using System.Text.Json;
using Microsoft.Extensions.ObjectPool;
using StitchATon.Services;
using StitchATon.Utility;
var builder = WebApplication.CreateBuilder( args );
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var path = Environment.GetEnvironmentVariable( "ASSET_PATH_RO" );
if( path == null )
throw new ArgumentException("Please supply the directory path on ASSET_PATH_RO env var");
// Image Loader
builder.Services.AddSingleton( new ImageProvider.Config(
path,
720,
55,
31) );
builder.Services.AddSingleton<ImageProvider>();
// FIFO named pipe pool
builder.Services.AddSingleton<ObjectPool<PngNamedPipe>>( new DefaultObjectPool<PngNamedPipe>(
new DefaultPooledObjectPolicy<PngNamedPipe>(),
10 ) );
builder.Services.AddControllers().AddJsonOptions( options =>
{
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower;
options.JsonSerializerOptions.WriteIndented = true;
}
);
builder.Logging.AddConsole();
var app = builder.Build();
// Configure the HTTP request pipeline.
if( app.Environment.IsDevelopment() )
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseCors();
app.UseRouting();
app.MapControllers();
app.Run();