AdminPanel
This commit is contained in:
+24
@@ -20,6 +20,24 @@ using VoidScavengers.Game;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddControllers();
|
||||
|
||||
// ---- Razor Pages for Admin Panel ----
|
||||
builder.Services.AddRazorPages()
|
||||
.AddRazorPagesOptions(options =>
|
||||
{
|
||||
options.RootDirectory = "/Admin/Pages";
|
||||
});
|
||||
|
||||
// ---- Session for Admin Auth ----
|
||||
builder.Services.AddDistributedMemoryCache();
|
||||
builder.Services.AddSession(options =>
|
||||
{
|
||||
options.IdleTimeout = TimeSpan.FromHours(8);
|
||||
options.Cookie.HttpOnly = true;
|
||||
options.Cookie.IsEssential = true;
|
||||
options.Cookie.Name = ".VoidScavengers.Admin";
|
||||
});
|
||||
|
||||
// ---- MySQL conn string from env ----
|
||||
string mysqlConnectionString = ConnectionStringFactory.BuildMySqlFromEnv();
|
||||
|
||||
@@ -153,6 +171,9 @@ app.MapGet("/health/ready", async (IRedisManager rm, HealthCheckService hc) =>
|
||||
catch { return Results.StatusCode(503); }
|
||||
});
|
||||
|
||||
// ---- Session middleware (must be before routing) ----
|
||||
app.UseSession();
|
||||
|
||||
// ---- WebSockets endpoint ----
|
||||
app.UseWebSockets(new WebSocketOptions { KeepAliveInterval = TimeSpan.FromSeconds(20) });
|
||||
|
||||
@@ -197,4 +218,7 @@ app.Lifetime.ApplicationStopping.Register(() =>
|
||||
// var leases = app.Services.GetRequiredService<IZoneLeaseService>();
|
||||
// _ = leases.TryAcquireAsync(zoneId: 1);
|
||||
app.MapControllers();
|
||||
app.MapRazorPages();
|
||||
|
||||
app.Logger.LogInformation("Admin panel available at /admin");
|
||||
await app.RunAsync();
|
||||
|
||||
Reference in New Issue
Block a user