2024-08-30 13:29:48 +00:00
|
|
|
using System.Text;
|
2020-06-06 22:51:21 +00:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Mvc.Formatters;
|
|
|
|
|
2023-01-31 11:18:10 +00:00
|
|
|
namespace Jellyfin.Api.Formatters;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Css output formatter.
|
|
|
|
/// </summary>
|
|
|
|
public class CssOutputFormatter : TextOutputFormatter
|
2020-06-06 22:51:21 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
2023-01-31 11:18:10 +00:00
|
|
|
/// Initializes a new instance of the <see cref="CssOutputFormatter"/> class.
|
2020-06-06 22:51:21 +00:00
|
|
|
/// </summary>
|
2023-01-31 11:18:10 +00:00
|
|
|
public CssOutputFormatter()
|
2020-06-06 22:51:21 +00:00
|
|
|
{
|
2023-01-31 11:18:10 +00:00
|
|
|
SupportedMediaTypes.Add("text/css");
|
2020-06-06 22:51:21 +00:00
|
|
|
|
2023-01-31 11:18:10 +00:00
|
|
|
SupportedEncodings.Add(Encoding.UTF8);
|
|
|
|
SupportedEncodings.Add(Encoding.Unicode);
|
|
|
|
}
|
2020-06-06 22:51:21 +00:00
|
|
|
|
2023-01-31 11:18:10 +00:00
|
|
|
/// <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);
|
2020-06-06 22:51:21 +00:00
|
|
|
}
|
2020-06-06 22:52:23 +00:00
|
|
|
}
|