mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 03:26:07 +02:00
Merge pull request #3260 from crobibero/api-css-formatter
Api css formatter
This commit is contained in:
commit
26f937c369
2 changed files with 38 additions and 0 deletions
|
@ -77,6 +77,8 @@ namespace Jellyfin.Server.Extensions
|
|||
opts.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 up
|
||||
|
|
36
Jellyfin.Server/Formatters/CssOutputFormatter.cs
Normal file
36
Jellyfin.Server/Formatters/CssOutputFormatter.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
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.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());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue