jellyfin/Jellyfin.Api/Formatters/CssOutputFormatter.cs
Bond_009 97a02f5803 Remove BOM from UTF-8 files
I think some people need to change their IDE configuration ;)
2024-08-30 15:29:48 +02:00

36 lines
1.1 KiB
C#

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