Improved asset service. Removed now unused plugin asset streaming endpoint

This commit is contained in:
2024-12-01 20:04:29 +01:00
parent 0a76e64d2f
commit 62fe6089f7
6 changed files with 83 additions and 54 deletions

View File

@@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc;
using Moonlight.ApiServer.Services;
using Moonlight.Shared.Http.Responses.Assets;
namespace Moonlight.ApiServer.Http.Controllers;
namespace Moonlight.ApiServer.Http.Controllers.Assets;
[ApiController]
[Route("api/assets")]
@@ -20,8 +20,8 @@ public class AssetsController : Controller
{
return new FrontendAssetResponse()
{
CssFiles = AssetService.CssFiles.ToArray(),
JavascriptFiles = AssetService.JavascriptFiles.ToArray(),
CssFiles = AssetService.GetCssAssets(),
JavascriptFiles = AssetService.GetJavascriptAssets(),
};
}
}

View File

@@ -1,23 +1,19 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using MoonCore.Exceptions;
using MoonCore.Models;
using Moonlight.ApiServer.Services;
using Moonlight.Shared.Http.Responses.PluginsStream;
namespace Moonlight.ApiServer.Http.Controllers;
namespace Moonlight.ApiServer.Http.Controllers.Assets;
[ApiController]
[Route("api/pluginsStream")]
public class PluginsStreamController : Controller
[Route("api/assets/plugins")]
public class AssetsPluginsController : Controller
{
private readonly PluginService PluginService;
private readonly IMemoryCache Cache;
public PluginsStreamController(PluginService pluginService, IMemoryCache cache)
public AssetsPluginsController(PluginService pluginService)
{
PluginService = pluginService;
Cache = cache;
}
[HttpGet]
@@ -29,7 +25,7 @@ public class PluginsStreamController : Controller
[HttpGet("stream")]
public async Task GetAssembly([FromQuery(Name = "assembly")] string assembly)
{
var assembliesMap = PluginService.AssemblyMap;
var assembliesMap = PluginService.ClientAssemblyMap;
if (assembliesMap.ContainsKey(assembly))
throw new HttpApiException("The requested assembly could not be found", 404);
@@ -38,10 +34,4 @@ public class PluginsStreamController : Controller
await Results.File(path).ExecuteAsync(HttpContext);
}
[HttpGet("assets")]
public Task<PluginsAssetManifest> GetAssetManifest()
{
return Task.FromResult(PluginService.PluginsAssetManifest);
}
}