Add xml output formatter
This commit is contained in:
parent
f505f48e85
commit
2d4e91c5a2
|
@ -154,6 +154,7 @@ namespace Jellyfin.Server.Extensions
|
||||||
opts.OutputFormatters.Insert(0, new PascalCaseJsonProfileFormatter());
|
opts.OutputFormatters.Insert(0, new PascalCaseJsonProfileFormatter());
|
||||||
|
|
||||||
opts.OutputFormatters.Add(new CssOutputFormatter());
|
opts.OutputFormatters.Add(new CssOutputFormatter());
|
||||||
|
opts.OutputFormatters.Add(new XmlOutputFormatter());
|
||||||
})
|
})
|
||||||
|
|
||||||
// Clear app parts to avoid other assemblies being picked up
|
// Clear app parts to avoid other assemblies being picked up
|
||||||
|
|
30
Jellyfin.Server/Formatters/XmlOutputFormatter.cs
Normal file
30
Jellyfin.Server/Formatters/XmlOutputFormatter.cs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Formatters;
|
||||||
|
|
||||||
|
namespace Jellyfin.Server.Formatters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Xml output formatter.
|
||||||
|
/// </summary>
|
||||||
|
public class XmlOutputFormatter : TextOutputFormatter
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="XmlOutputFormatter"/> class.
|
||||||
|
/// </summary>
|
||||||
|
public XmlOutputFormatter()
|
||||||
|
{
|
||||||
|
SupportedMediaTypes.Add("text/xml");
|
||||||
|
SupportedMediaTypes.Add("text/xml;charset=UTF-8");
|
||||||
|
SupportedEncodings.Add(Encoding.UTF8);
|
||||||
|
SupportedEncodings.Add(Encoding.Unicode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
|
||||||
|
{
|
||||||
|
return context.HttpContext.Response.WriteAsync(context.Object?.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user