2.2 KiB
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
IModuleimplementeren en niet abstract zijn.
- Error Handling (Soft Fail):
- Bij het laden van een module wordt de aanroep van
RegisterServicesenUseModuleomgeven door eentry-catchblok. - Fouten worden gelogd als
Errornaar deILogger. - De orkestratie gaat door naar de volgende module om de algehele beschikbaarheid te maximaliseren.
- Bij het laden van een module wordt de aanroep van
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
DocInclusionPredicateom controllers te taggen op basis van hun assembly prefix (bijv.Availability). - JWT Support:
AddSecurityDefinition("Bearer", ...)AddSecurityRequirement(...)
- Pad: Beschikbaar op
/swaggerviaapp.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
}
}