mirror of
https://github.com/MikuLeaks/KianaBH3.git
synced 2025-12-14 13:54:43 +01:00
Init enter game
This commit is contained in:
53
SdkServer/SdkServer.cs
Normal file
53
SdkServer/SdkServer.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using KianaBH.SdkServer.Utils;
|
||||
using KianaBH.Util;
|
||||
using Microsoft.AspNetCore;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace KianaBH.SdkServer;
|
||||
|
||||
public class SdkServer
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
BuildWebHost(args).Start();
|
||||
}
|
||||
|
||||
private static IWebHost BuildWebHost(string[] args)
|
||||
{
|
||||
var builder = WebHost.CreateDefaultBuilder(args)
|
||||
.UseStartup<Startup>()
|
||||
.ConfigureLogging((_, logging) => { logging.ClearProviders(); })
|
||||
.UseUrls(ConfigManager.Config.HttpServer.GetBindDisplayAddress());
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
}
|
||||
|
||||
public class Startup
|
||||
{
|
||||
public static void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment()) app.UseDeveloperExceptionPage();
|
||||
|
||||
app.UseRouting();
|
||||
app.UseCors("AllowAll");
|
||||
app.UseAuthorization();
|
||||
app.UseMiddleware<RequestLoggingMiddleware>();
|
||||
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
|
||||
}
|
||||
|
||||
public static void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("AllowAll",
|
||||
builder => { builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader(); });
|
||||
});
|
||||
services.AddControllers()
|
||||
.AddJsonOptions(options =>
|
||||
{
|
||||
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower;
|
||||
});
|
||||
services.AddSingleton<Logger>(_ => new Logger("HttpServer"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user