using Acl.Application; using Acl.Infrastructure; var builder = WebApplication.CreateBuilder(args); builder.Services.AddSingleton(); builder.Services.AddSingleton(sp => sp.GetRequiredService() .GetSection("Acl:Defaults").Get() ?? throw new InvalidOperationException("Missing configuration section 'Acl:Defaults'")); builder.Services.AddSingleton(sp => sp.GetRequiredService() .GetSection("Acl:OpenZaak").Get() ?? throw new InvalidOperationException("Missing configuration section 'Acl:OpenZaak'")); builder.Services.AddHttpClient(); builder.Services.AddScoped(); var app = builder.Build(); app.MapGet("/health", () => "Healthy"); // The ACL's single operation, exposed as a service endpoint. app.MapPost("/zaken", async (OpenZaakRequest body, AclService acl, CancellationToken ct) => { var zaakUrl = await acl.OpenZaakAsync(new DomainRegistration(body.Bsn), ct); return Results.Ok(new { zaakUrl = zaakUrl.ToString() }); }); // Approve a zaak: set it to its zaaktype's eindstatus (S-09b). The domain hands over only the zaak // URL; the ACL owns the ZGW statustype resolution (ยง8.1). app.MapPost("/statussen", async (SetStatusRequest body, AclService acl, CancellationToken ct) => { await acl.ApproveZaakAsync(new Uri(body.ZaakUrl), ct); return Results.NoContent(); }); app.Run(); public sealed record OpenZaakRequest(string Bsn); public sealed record SetStatusRequest(string ZaakUrl); public partial class Program;