Program.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using Electric.Domain.DependencyInjection;
  2. using Electric.Application.DependencyInjection;
  3. using Electric.Application.Helpers;
  4. using Electric.Application.Auth;
  5. var builder = WebApplication.CreateBuilder(args);
  6. // Add services to the container.
  7. builder.Services.AddControllers();
  8. // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
  9. builder.Services.AddEndpointsApiExplorer();
  10. builder.Services.AddDomain();
  11. builder.Services.AddSingleton(new AppSettingsHelper());
  12. #region JWT×¢Èë
  13. var jwtBearer = new JwtBearerSetting(
  14. AppSettingsHelper.ReadString("JWTSettings:ValidIssuer"),
  15. AppSettingsHelper.ReadString("JWTSettings:ValidAudience"),
  16. AppSettingsHelper.ReadString("JWTSettings:IssuerSigningKey"));
  17. builder.Services.AddJWT(jwtBearer);
  18. #endregion JWT×¢Èë
  19. builder.Services.AddSwaggerGen();
  20. builder.Services.AddApplication();
  21. var app = builder.Build();
  22. // Configure the HTTP request pipeline.
  23. if (app.Environment.IsDevelopment())
  24. {
  25. app.UseSwagger();
  26. app.UseSwaggerUI();
  27. }
  28. app.UseHttpsRedirection();
  29. app.UseAuthorization();
  30. app.MapControllers();
  31. app.Run();