37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using static DeluxeBackend.Enums;
|
|
using System.Text.Json;
|
|
|
|
namespace DeluxeBackend.Controllers.Api
|
|
{
|
|
[Route("api/gameconfigs")]
|
|
[ApiController]
|
|
public class GameConfigsController : ControllerBase
|
|
{
|
|
private readonly List<GameConfigDto> gameConfigDtos = [];
|
|
|
|
public GameConfigsController()
|
|
{
|
|
if (gameConfigDtos.Count == 0)
|
|
{
|
|
var json = System.IO.File.ReadAllText(Path.Combine("data", "GameConfigs.json"));
|
|
var gameConfigs = JsonSerializer.Deserialize<List<GameConfigDto>>(json);
|
|
gameConfigDtos.AddRange(gameConfigs);
|
|
}
|
|
}
|
|
public class GameConfigDto
|
|
{
|
|
public required string Key { get; set; }
|
|
public required string Value { get; set; }
|
|
public string? ActiveExperiments { get; set; } = null;
|
|
}
|
|
|
|
[HttpGet("v1/all")]
|
|
public async Task<IActionResult> List()
|
|
{
|
|
return Ok(gameConfigDtos);
|
|
}
|
|
}
|
|
}
|