Program.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System.Text.Json.Serialization;
  2. using ImageConvertService.Biz;
  3. using ImageConvertService.ExceptionHandling;
  4. using Microsoft.AspNetCore.Server.Kestrel.Core;
  5. var builder = WebApplication.CreateBuilder(args);
  6. // Add services to the container.
  7. // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
  8. builder.Services.AddEndpointsApiExplorer();
  9. builder.Services.AddSwaggerGen();
  10. builder.Services
  11. .AddControllersWithViews(options => options.Filters.Add<UserFriendlyExceptionFilter>())
  12. .AddJsonOptions(options => options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()));
  13. builder.Services.AddSingleton<ArchiveFileAccessor>();
  14. builder.Services.AddSingleton<ArchiveEntrySkipper>();
  15. builder.Services.AddSingleton<PdfImageReader>();
  16. builder.Services.AddSingleton<ImageConverter>();
  17. builder.Services.Configure<KestrelServerOptions>(options =>
  18. {
  19. options.Limits.MaxRequestBodySize = 8000 * 1024 * 1024L; // 设置最大请求体大小 8GB
  20. });
  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.AddExample();
  30. app.MapControllers().WithFormOptions(multipartBodyLengthLimit: 8000 * 1024 * 1024L); // 设置表单最大请求体大小 8GB
  31. app.Run();