using lilos_stitcher;
using Microsoft.AspNetCore.Mvc;

namespace LiloStitcher;

[ApiController]
[Route( "api/image" )]
public sealed class LiloController( lilos_stitcher.LiloStitcher stitcher ) : ControllerBase
{
  [HttpPost]
  [Route( "generate" )]
  [Produces( "image/png" )]
  public async Task<IActionResult> Generate( [FromBody] GenerateRequest payload, CancellationToken ct )
  {
    string path = await stitcher.CreateImageAsync( payload, ct );
    return PhysicalFile(path, "image/png", enableRangeProcessing: false);
  }
}