Skip to content

Commit

Permalink
Fix URL compatibility paths
Browse files Browse the repository at this point in the history
I guess I forgot to test these. Whoops.
  • Loading branch information
PJB3005 committed Jul 14, 2024
1 parent f454132 commit 1b580c5
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions Robust.Cdn/Controllers/DownloadCompatibilityController.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Robust.Cdn.Config;
using Robust.Cdn.Services;

namespace Robust.Cdn.Controllers;

[ApiController]
[Route("/version/{version}")]
public sealed class DownloadCompatibilityController(
DownloadController downloadController,
IOptions<CdnOptions> cdnOptions) : ControllerBase
Database db,
ILogger<DownloadController> logger,
IOptionsSnapshot<CdnOptions> cdnOptions,
DownloadRequestLogger requestLogger) : ControllerBase
{
[HttpGet("manifest")]
public IActionResult GetManifest(string version)
{
if (cdnOptions.Value.DefaultFork is not { } defaultFork)
return NotFound();

return downloadController.GetManifest(defaultFork, version);
return GetDownloadController().GetManifest(defaultFork, version);
}

[HttpOptions("download")]
Expand All @@ -25,7 +28,7 @@ public IActionResult DownloadOptions(string version)
if (cdnOptions.Value.DefaultFork is not { } defaultFork)
return NotFound();

return downloadController.DownloadOptions(defaultFork, version);
return GetDownloadController().DownloadOptions(defaultFork, version);
}

[HttpPost("download")]
Expand All @@ -34,6 +37,14 @@ public async Task<IActionResult> Download(string version)
if (cdnOptions.Value.DefaultFork is not { } defaultFork)
return NotFound();

return await downloadController.Download(defaultFork, version);
return await GetDownloadController().Download(defaultFork, version);
}

private DownloadController GetDownloadController()
{
return new DownloadController(db, logger, cdnOptions, requestLogger)
{
ControllerContext = ControllerContext
};
}
}

0 comments on commit 1b580c5

Please sign in to comment.