The Free Software Media System - Server Backend & API
Add CSS output formatter.
crobibero598cd94c4d5f
diff --git a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.csindex cb4189587d..1c7fcbc066 100644--- a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs+++ b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs@@ -77,6 +77,8 @@ namespace Jellyfin.Server.Extensionsopts.UseGeneralRoutePrefix(baseUrl);opts.OutputFormatters.Insert(0, new CamelCaseJsonProfileFormatter());opts.OutputFormatters.Insert(0, new PascalCaseJsonProfileFormatter());++ opts.OutputFormatters.Add(new CssOutputFormatter());})// Clear app parts to avoid other assemblies being picked updiff --git a/Jellyfin.Server/Formatters/CssOutputFormatter.cs b/Jellyfin.Server/Formatters/CssOutputFormatter.csnew file mode 100644index 0000000000..b26e7f96a0--- /dev/null+++ b/Jellyfin.Server/Formatters/CssOutputFormatter.cs@@ -0,0 +1,37 @@+using System;+using System.Text;+using System.Threading.Tasks;+using Microsoft.AspNetCore.Http;+using Microsoft.AspNetCore.Mvc.Formatters;++namespace Jellyfin.Server.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.Clear();+ 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)+ {+ return context.HttpContext.Response.WriteAsync(context.Object?.ToString());+ }+ }+}\ No newline at end of file