File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
src/DotNetElements.AppFramework.AspNet Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 1+ using Microsoft . AspNetCore . Builder ;
2+
3+ namespace DotNetElements . AppFramework . AspNet ;
4+
5+ // todo better error handling
6+ public interface IStartupModule
7+ {
8+ Task InitAsync ( WebApplication app ) ;
9+ }
Original file line number Diff line number Diff line change @@ -15,6 +15,15 @@ public static WebApplication MapModuleEndpoints(this WebApplication app)
1515 return app ;
1616 }
1717
18+ // todo better error handling
19+ public static async Task InitModulesAsync ( this WebApplication app )
20+ {
21+ ArgumentNullException . ThrowIfNull ( WebApplicationBuilderExtensions . RegisteredModules ) ;
22+
23+ foreach ( IStartupModule module in WebApplicationBuilderExtensions . RegisteredModules . OfType < IStartupModule > ( ) )
24+ await module . InitAsync ( app ) ;
25+ }
26+
1827 public static WebApplication MigrateDatabase < TDbContext > ( this WebApplication app )
1928 where TDbContext : DbContext
2029 {
Original file line number Diff line number Diff line change @@ -6,12 +6,12 @@ namespace DotNetElements.AppFramework.AspNet;
66
77public static class WebApplicationExtensions
88{
9- public static WebApplication UseAppFramework ( this WebApplication app )
9+ public static async Task UseAppFrameworkAsync ( this WebApplication app )
1010 {
1111 app . UseSerilogRequestLogging ( ) ;
1212
1313 app . MapModuleEndpoints ( ) ;
1414
15- return app ;
15+ await app . InitModulesAsync ( ) ;
1616 }
1717}
You can’t perform that action at this time.
0 commit comments