28 lines
871 B
C#
28 lines
871 B
C#
|
|
using System.Text.Json.Serialization;
|
||
|
|
using StitchATon2.App.Controllers;
|
||
|
|
using StitchATon2.App.Models;
|
||
|
|
using StitchATon2.Domain;
|
||
|
|
|
||
|
|
var builder = WebApplication.CreateSlimBuilder(args);
|
||
|
|
|
||
|
|
using var tileManager = new TileManager(Configuration.Default);
|
||
|
|
builder.Services.AddSingleton(tileManager);
|
||
|
|
|
||
|
|
builder.Services.ConfigureHttpJsonOptions(options =>
|
||
|
|
{
|
||
|
|
options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
|
||
|
|
});
|
||
|
|
|
||
|
|
var app = builder.Build();
|
||
|
|
|
||
|
|
app.MapPost("/api/image/generate", ImageController.GenerateImage);
|
||
|
|
app.MapGet("/api/image/generate/random", ImageController.GenerateRandomImage);
|
||
|
|
|
||
|
|
app.Run();
|
||
|
|
|
||
|
|
[JsonSourceGenerationOptions(WriteIndented = false)]
|
||
|
|
[JsonSerializable(typeof(GenerateImageDto))]
|
||
|
|
[JsonSerializable(typeof(Dictionary<string,List<string>>))]
|
||
|
|
internal partial class AppJsonSerializerContext : JsonSerializerContext
|
||
|
|
{
|
||
|
|
}
|