| name | new-extension |
| description | Create a new modular infrastructure extension. Use when: adding a new infrastructure feature, integrating a new service provider, creating middleware, adding a new cross-cutting concern. |
| argument-hint | Extension name (e.g., Redis Streams) |
New Infrastructure Extension
Creates a modular infrastructure extension following the project's established pattern of 17+ extensions.
When to Use
- Adding a new infrastructure feature (message broker, etc.)
- Integrating a new third-party service
- Adding new middleware or cross-cutting concerns
Procedure
1. Configuration
- Add configuration section to
src/Server/Domain/AppSettings.cs under Infrastructure
public class MyFeatureSettings
{
public bool Enabled { get; set; }
}
2. Extension Class
- Create
src/Server/Infrastructure/Extensions/MyFeatureExtension.cs
public static class MyFeatureExtension
{
public static IServiceCollection AddMyFeature(
this IServiceCollection services, AppSettings settings)
{
if (!settings.Infrastructure.MyFeature.Enabled) return services;
return services;
}
public static IApplicationBuilder UseMyFeature(
this IApplicationBuilder app, AppSettings settings)
{
if (!settings.Infrastructure.MyFeature.Enabled) return app;
return app;
}
}
3. Registration
- Register in
src/Server/Infrastructure/Extensions/InfrastructureExtensions.cs:
- Add
services.AddMyFeature(settings); in AddInfrastructure
- Add
app.UseMyFeature(settings); in UseInfrastructure (if middleware needed)
4. Configuration Files
- Add default settings to
src/Server/Api/appsettings.json under AppSettings.Infrastructure
- Document the feature in
docs/ if complex
5. Tests
- Add unit test for the extension registration
Reference
- Orchestrator:
src/Server/Infrastructure/Extensions/InfrastructureExtensions.cs