Merge branch 'p2-w5-stream-now' into dev
This commit is contained in:
@@ -59,6 +59,39 @@ public class TrackProxyController : ControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Proxies the random-track metadata lookup from DeepDrftAPI. Unauthenticated, same posture as
|
||||
/// the paged listing. Small JSON, buffered and relayed; a 404 from upstream (empty library)
|
||||
/// passes through so the client renders it as a valid empty state. Declared before the
|
||||
/// parameterized "{trackId}" route so the literal segment is never treated as a trackId.
|
||||
/// </summary>
|
||||
[HttpGet("random")]
|
||||
public async Task<ActionResult> GetRandom(CancellationToken ct = default)
|
||||
{
|
||||
HttpResponseMessage upstream;
|
||||
try
|
||||
{
|
||||
upstream = await _upstream.GetAsync("api/track/random", HttpCompletionOption.ResponseHeadersRead, ct);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Upstream call to DeepDrftAPI track/random failed");
|
||||
return StatusCode(502, "Upstream unavailable");
|
||||
}
|
||||
|
||||
using (upstream)
|
||||
{
|
||||
if (!upstream.IsSuccessStatusCode)
|
||||
{
|
||||
_logger.LogWarning("DeepDrftAPI track/random returned {Status}", (int)upstream.StatusCode);
|
||||
return StatusCode((int)upstream.StatusCode);
|
||||
}
|
||||
|
||||
var json = await upstream.Content.ReadAsStringAsync(ct);
|
||||
return Content(json, "application/json");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Proxies single-track metadata lookup by vault entry key from DeepDrftAPI. Unauthenticated,
|
||||
/// same posture as the paged listing. Small JSON, so it is buffered and relayed; a 404 from
|
||||
|
||||
Reference in New Issue
Block a user