using System; using System.IO; using System.Reflection; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Jellyfin.Plugin.JRay.Controllers; /// /// Serves static client-side assets for JRay, e.g. the pause-overlay script /// injected into the web client. /// [ApiController] [Route("Plugins/JRay")] [AllowAnonymous] public class WebController : ControllerBase { private const string OverlayScriptResource = "Jellyfin.Plugin.JRay.Web.jray-overlay.js"; /// /// Gets the pause-overlay client script. /// /// The JavaScript source for the pause overlay. [HttpGet("ClientScript")] [ProducesResponseType(StatusCodes.Status200OK)] public IActionResult GetClientScript() { var assembly = Assembly.GetExecutingAssembly(); var stream = assembly.GetManifestResourceStream(OverlayScriptResource) ?? throw new InvalidOperationException($"Embedded resource '{OverlayScriptResource}' not found."); return File(stream, "application/javascript"); } }