Files
slp-modular-cms/aidlc-docs/features/slp-modular-cms-api/construction/api-shell/nfr-design/orchestration-design.md
T

2.2 KiB

Orchestration Design — Unit 04: API Shell & Integration

Dit document beschrijft de technische implementatie van de module orkestratie.

1. ModuleOrchestrator

De orchestrator is verantwoordelijk voor de lifecycle van modules.

  • Discovery:
    • Gebruikt Reflection om alle typen in geladen assemblies te scannen.
    • Filtert op klassen die IModule implementeren en niet abstract zijn.
  • Error Handling (Soft Fail):
    • Bij het laden van een module wordt de aanroep van RegisterServices en UseModule omgeven door een try-catch blok.
    • Fouten worden gelogd als Error naar de ILogger.
    • De orkestratie gaat door naar de volgende module om de algehele beschikbaarheid te maximaliseren.

2. Route Conventions

De /api/v1/ prefix wordt afgedwongen via een custom IApplicationModelConvention:

public class ApiPrefixConvention : IApplicationModelConvention
{
    public void Apply(ApplicationModel application)
    {
        foreach (var controller in application.Controllers)
        {
            foreach (var selector in controller.Selectors)
            {
                // Voeg prefix toe aan bestaande route
                var routePrefix = new AttributeRouteModel(new RouteAttribute("api/v1"));
                selector.AttributeRouteModel = selector.AttributeRouteModel != null 
                    ? AttributeRouteModel.CombineAttributeRouteModels(routePrefix, selector.AttributeRouteModel) 
                    : routePrefix;
            }
        }
    }
}

3. Swagger & Security Design

Swagger wordt geconfigureerd in Program.cs:

  • Groepering: Gebruik van DocInclusionPredicate om controllers te taggen op basis van hun assembly prefix (bijv. Availability).
  • JWT Support:
    • AddSecurityDefinition("Bearer", ...)
    • AddSecurityRequirement(...)
  • Pad: Beschikbaar op /swagger via app.UseSwaggerUI(c => c.RoutePrefix = "swagger").

4. CORS Global Configuration

De Shell leest de CorsSettings uit appsettings.json en configureert een globale policy:

{
  "CorsSettings": {
    "AllowedOrigins": ["https://portal.slp-modular.local"],
    "AllowAnyHeader": true,
    "AllowAnyMethod": true
  }
}