| | 1 | | using System.Text; |
| | 2 | | using System.Threading.Tasks; |
| | 3 | | using Microsoft.AspNetCore.Http; |
| | 4 | | using Microsoft.AspNetCore.Mvc.Formatters; |
| | 5 | |
|
| | 6 | | namespace Jellyfin.Api.Formatters; |
| | 7 | |
|
| | 8 | | /// <summary> |
| | 9 | | /// Css output formatter. |
| | 10 | | /// </summary> |
| | 11 | | public class CssOutputFormatter : TextOutputFormatter |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// Initializes a new instance of the <see cref="CssOutputFormatter"/> class. |
| | 15 | | /// </summary> |
| 22 | 16 | | public CssOutputFormatter() |
| | 17 | | { |
| 22 | 18 | | SupportedMediaTypes.Add("text/css"); |
| | 19 | |
|
| 22 | 20 | | SupportedEncodings.Add(Encoding.UTF8); |
| 22 | 21 | | SupportedEncodings.Add(Encoding.Unicode); |
| 22 | 22 | | } |
| | 23 | |
|
| | 24 | | /// <summary> |
| | 25 | | /// Write context object to stream. |
| | 26 | | /// </summary> |
| | 27 | | /// <param name="context">Writer context.</param> |
| | 28 | | /// <param name="selectedEncoding">Unused. Writer encoding.</param> |
| | 29 | | /// <returns>Write stream task.</returns> |
| | 30 | | public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding) |
| | 31 | | { |
| 2 | 32 | | var stringResponse = context.Object?.ToString(); |
| 2 | 33 | | return stringResponse is null ? Task.CompletedTask : context.HttpContext.Response.WriteAsync(stringResponse); |
| | 34 | | } |
| | 35 | | } |