AppServer.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using WebTemplate.ServerAspects.Auth;
  2. using WebTemplate.ServerAspects.Cors;
  3. using WebTemplate.ServerAspects.Spa;
  4. using WebTemplate.ServerAspects.Swagger;
  5. namespace WebTemplate;
  6. public class AppServer
  7. {
  8. private readonly IList<IAppConfigurationModule> _modules = new List<IAppConfigurationModule>
  9. {
  10. new AuthModule(),
  11. new CorsModule(),
  12. new SpaRoutingModule(),
  13. new SwaggerModule(),
  14. //new ApiControllersModule(),
  15. };
  16. public void Start(string[] args)
  17. {
  18. var builder = WebApplication.CreateBuilder(args);
  19. //builder.Configuration.AddJsonFile()
  20. foreach (var appConfigurationModule in _modules)
  21. {
  22. appConfigurationModule.ConfigureServices(builder.Services, builder.Configuration);
  23. }
  24. var app = builder.Build();
  25. app.UseHttpsRedirection();
  26. foreach (var appConfigurationModule in _modules)
  27. {
  28. appConfigurationModule.ConfigureApplication(app);
  29. }
  30. app.Run();
  31. }
  32. }