using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Formatters;
namespace Jellyfin.Api.Formatters;
///
/// Css output formatter.
///
public class CssOutputFormatter : TextOutputFormatter
{
///
/// Initializes a new instance of the class.
///
public CssOutputFormatter()
{
SupportedMediaTypes.Add("text/css");
SupportedEncodings.Add(Encoding.UTF8);
SupportedEncodings.Add(Encoding.Unicode);
}
///
/// Write context object to stream.
///
/// Writer context.
/// Unused. Writer encoding.
/// Write stream task.
public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
{
var stringResponse = context.Object?.ToString();
return stringResponse is null ? Task.CompletedTask : context.HttpContext.Response.WriteAsync(stringResponse);
}
}