using Microsoft.AspNetCore.Mvc;
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests.ImmutableData;
using SVSim.EmulatedEntrypoint.Models.Dtos.Responses.ImmutableData;
using SVSim.EmulatedEntrypoint.Services;
namespace SVSim.EmulatedEntrypoint.Controllers;
///
/// Family /immutable_data/*. v1 hosts the single endpoint card_master;
/// future siblings (e.g. mission masters, asset bundle hash tables) would land here.
///
[Route("immutable_data")]
public class ImmutableDataController : SVSimController
{
private readonly ICardMasterPayloadProvider _provider;
public ImmutableDataController(ICardMasterPayloadProvider provider)
{
_provider = provider;
}
///
/// Returns the base64+gzip+json+csv card-master payload. Tier 1 serves a static prod
/// snapshot regardless of the request's card_master_hash; freshness gating is
/// handled on /load/index instead.
///
[HttpPost("card_master")]
public ActionResult CardMaster([FromBody] CardMasterRequest req)
{
if (!_provider.IsAvailable)
{
// 500 not 503: blob missing is operator error (config / build), not transient — no retry will help.
return StatusCode(500, "card-master payload not available");
}
return Ok(new CardMasterResponse { CardMaster = _provider.Base64Blob });
}
}