refactor: sped up game list loading code, plus many small bug fixes

This commit is contained in:
Michael Green
2023-06-27 23:31:29 +10:00
parent 3f269d802b
commit ee4e5d4037
12 changed files with 315 additions and 210 deletions

View File

@@ -1,6 +1,7 @@
using System.Text.Json.Serialization;
using gaseous_server;
using gaseous_tools;
using Microsoft.AspNetCore.Mvc;
Logging.Log(Logging.LogType.Information, "Startup", "Starting Gaseous Server");
@@ -32,6 +33,27 @@ builder.Services.AddControllers().AddJsonOptions(x =>
// suppress nulls
x.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
});
builder.Services.AddResponseCaching();
builder.Services.AddControllers(options =>
{
options.CacheProfiles.Add("Default30",
new CacheProfile()
{
Duration = 30
});
options.CacheProfiles.Add("5Minute",
new CacheProfile()
{
Duration = 300,
Location = ResponseCacheLocation.Any
});
options.CacheProfiles.Add("7Days",
new CacheProfile()
{
Duration = 604800,
Location = ResponseCacheLocation.Any
});
});
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
@@ -49,6 +71,8 @@ if (app.Environment.IsDevelopment())
app.UseHttpsRedirection();
app.UseResponseCaching();
app.UseAuthorization();
app.UseDefaultFiles();