jellyfin/MediaBrowser.Common/Net/Handlers/BaseEmbeddedResourceHandler.cs
LukePulverenti Luke Pulverenti luke pulverenti fbf8cc833c a few more async optimizations
2012-08-21 22:50:59 -04:00

29 lines
789 B
C#

using System.IO;
using System.Threading.Tasks;
namespace MediaBrowser.Common.Net.Handlers
{
public abstract class BaseEmbeddedResourceHandler : BaseHandler
{
public BaseEmbeddedResourceHandler(string resourcePath)
: base()
{
ResourcePath = resourcePath;
}
protected string ResourcePath { get; set; }
public override Task<string> GetContentType()
{
return Task.FromResult<string>(MimeTypes.GetMimeType(ResourcePath));
}
protected override Task WriteResponseToOutputStream(Stream stream)
{
return GetEmbeddedResourceStream().CopyToAsync(stream);
}
protected abstract Stream GetEmbeddedResourceStream();
}
}