diff options
| author | crobibero <cody@robibe.ro> | 2020-08-15 10:39:24 -0600 |
|---|---|---|
| committer | crobibero <cody@robibe.ro> | 2020-08-15 10:39:24 -0600 |
| commit | 2d4e91c5a202aeb7b5d6d2206767d05a8f850212 (patch) | |
| tree | c3b07cba98337539282e3a88408099abdc71952f /Jellyfin.Server/Formatters/XmlOutputFormatter.cs | |
| parent | f505f48e8580833cb2d3a80413ab7b168aa61fe7 (diff) | |
Add xml output formatter
Diffstat (limited to 'Jellyfin.Server/Formatters/XmlOutputFormatter.cs')
| -rw-r--r-- | Jellyfin.Server/Formatters/XmlOutputFormatter.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Jellyfin.Server/Formatters/XmlOutputFormatter.cs b/Jellyfin.Server/Formatters/XmlOutputFormatter.cs new file mode 100644 index 000000000..5f2337b2a --- /dev/null +++ b/Jellyfin.Server/Formatters/XmlOutputFormatter.cs @@ -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()); + } + } +} |
