Program.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using AipGateway.API.Application.Pipeline.Middlewares;
  2. using AipGateway.API.Extensions;
  3. using AipGateway.API.Domain;
  4. internal class Program
  5. {
  6. private static void Main(string[] args)
  7. {
  8. var builder = WebApplication.CreateBuilder(args);
  9. // Add services to the container.
  10. builder.Services.AddControllers();
  11. // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
  12. builder.Services.AddEndpointsApiExplorer();
  13. builder.Services.UseSwagger(builder.Environment);
  14. builder.Services.InjectDependencies(builder.Configuration);
  15. builder.Services.AddHealthChecks();
  16. builder.Services.AddCors(p => p.AddPolicy("corsapp", builder =>
  17. {
  18. builder.WithOrigins("*", "http://localhost:3011", "https://localhost:3011", "https://localhost:7261").AllowAnyMethod().AllowAnyHeader();
  19. }));
  20. var app = builder.Build();
  21. //app.UseExceptionHandler("/Error");
  22. //HTTP Strict Transport Security : Method used by server to declare that they should only be accessed using HTTPS (secure connection) only
  23. app.UseHsts();
  24. app.UseHttpsRedirection();
  25. app.UseStaticFiles();
  26. app.UseRouting();
  27. app.UseCors("corsapp");
  28. app.UseAuthentication();
  29. app.UseAuthorization();
  30. app.UseMiddlewares();
  31. app.UseHealthChecks("/health");
  32. app.UseSwagger();
  33. app.UseSwaggerUI();
  34. app.MapSwagger();
  35. app.MapControllers();
  36. app.Run();
  37. }
  38. }