29 lines
733 B
C#
29 lines
733 B
C#
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc.Formatters;
|
|
using System;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace PartSource.Api.Formatters
|
|
{
|
|
public class LiquidTemplateOutputFormatter : TextOutputFormatter
|
|
{
|
|
public LiquidTemplateOutputFormatter()
|
|
{
|
|
SupportedMediaTypes.Add("application/liquid");
|
|
SupportedEncodings.Add(Encoding.UTF8);
|
|
SupportedEncodings.Add(Encoding.Unicode);
|
|
}
|
|
|
|
protected override bool CanWriteType(Type type)
|
|
{
|
|
return type == typeof(string);
|
|
}
|
|
|
|
public override async Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
|
|
{
|
|
await context.HttpContext.Response.WriteAsync((string)context.Object);
|
|
}
|
|
}
|
|
}
|