-
Notifications
You must be signed in to change notification settings - Fork 2
/
Program.cs
47 lines (39 loc) · 1.61 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System.Net;
using AndrealImageGenerator.Common;
using Microsoft.AspNetCore.Diagnostics;
using Newtonsoft.Json;
var builder = WebApplication.CreateBuilder(args);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.ServerCertificateValidationCallback = (
_,
_,
_,
_) => true;
ServicePointManager.DefaultConnectionLimit = 512;
ServicePointManager.Expect100Continue = false;
ServicePointManager.UseNagleAlgorithm = false;
ServicePointManager.ReusePort = true;
ServicePointManager.CheckCertificateRevocationList = true;
WebRequest.DefaultWebProxy = null;
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddControllers().AddNewtonsoftJson(options => options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore)
.ConfigureApiBehaviorOptions(options =>
{
options.SuppressModelStateInvalidFilter = true;
options.SuppressMapClientErrors = true;
});
var app = builder.Build();
app.UseExceptionHandler(new ExceptionHandlerOptions
{
ExceptionHandler = context =>
{
context.Response.Clear();
context.Response.StatusCode = 500;
var ex = context.Features.Get<IExceptionHandlerFeature>()?.Error;
if (ex != null) ExceptionLogger.Write(ex);
return Task.CompletedTask;
}
});
app.MapControllers();
app.Run();