mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-09-25 15:47:59 +03:00
44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace AMNet.Server;
|
|
|
|
internal static class WebServer
|
|
{
|
|
public static WebApplicationBuilder BuildServer()
|
|
{
|
|
var builder = WebApplication.CreateSlimBuilder([]);
|
|
|
|
builder.Logging.ClearProviders();
|
|
builder.Logging.AddSimpleConsole(o =>
|
|
{
|
|
o.SingleLine = true;
|
|
o.IncludeScopes = false;
|
|
});
|
|
|
|
builder.Logging.SetMinimumLevel(LogLevel.Information);
|
|
builder.Logging.AddFilter("Microsoft.AspNetCore.Http.Result", LogLevel.None);
|
|
builder.Logging.AddFilter("Microsoft.AspNetCore.Routing.EndpointMiddleware", LogLevel.Error);
|
|
|
|
builder.Services.AddCors(cors =>
|
|
{
|
|
cors.AddDefaultPolicy(policy =>
|
|
{
|
|
policy.AllowAnyMethod();
|
|
policy.AllowAnyOrigin();
|
|
policy.AllowAnyHeader();
|
|
|
|
policy.SetPreflightMaxAge(TimeSpan.FromHours(6));
|
|
});
|
|
});
|
|
|
|
builder.Services.ConfigureHttpJsonOptions(options =>
|
|
{
|
|
options.SerializerOptions.TypeInfoResolverChain.Insert(0, SerializerContext.Default);
|
|
});
|
|
|
|
return builder;
|
|
}
|
|
} |