Files
Moonlight/Moonlight.ApiServer/Helpers/BundleAssetFileProvider.cs
2024-12-10 16:28:11 +01:00

28 lines
844 B
C#

using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.FileProviders.Physical;
using Microsoft.Extensions.Primitives;
using MoonCore.Helpers;
namespace Moonlight.ApiServer.Helpers;
public class BundleAssetFileProvider : IFileProvider
{
public IDirectoryContents GetDirectoryContents(string subpath)
=> NotFoundDirectoryContents.Singleton;
public IFileInfo GetFileInfo(string subpath)
{
if(subpath != "/css/bundle.css")
return new NotFoundFileInfo(subpath);
var physicalPath = PathBuilder.File("storage", "tmp", "bundle.css");
if(!File.Exists(physicalPath))
return new NotFoundFileInfo(subpath);
return new PhysicalFileInfo(new FileInfo(physicalPath));
}
public IChangeToken Watch(string filter)
=> NullChangeToken.Singleton;
}