12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System.Text.Json.Serialization;
- using ImageConvertService.Biz;
- using ImageConvertService.ExceptionHandling;
- using Microsoft.AspNetCore.Server.Kestrel.Core;
- var builder = WebApplication.CreateBuilder(args);
- // Add services to the container.
- // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
- builder.Services.AddEndpointsApiExplorer();
- builder.Services.AddSwaggerGen();
- builder.Services
- .AddControllersWithViews(options => options.Filters.Add<UserFriendlyExceptionFilter>())
- .AddJsonOptions(options => options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()));
- builder.Services.AddSingleton<ArchiveFileAccessor>();
- builder.Services.AddSingleton<ArchiveEntrySkipper>();
- builder.Services.AddSingleton<PdfImageReader>();
- builder.Services.AddSingleton<ImageConverter>();
- builder.Services.Configure<KestrelServerOptions>(options =>
- {
- options.Limits.MaxRequestBodySize = 8000 * 1024 * 1024L; // 设置最大请求体大小 8GB
- });
- var app = builder.Build();
- // Configure the HTTP request pipeline.
- //if (app.Environment.IsDevelopment())
- //{
- app.UseSwagger();
- app.UseSwaggerUI();
- //}
- //app.UseHttpsRedirection();
- //app.AddExample();
- app.MapControllers().WithFormOptions(multipartBodyLengthLimit: 8000 * 1024 * 1024L); // 设置表单最大请求体大小 8GB
- app.Run();
|