Initial commit
This commit is contained in:
28
PartSource.Api/Formatters/LiquidTemplateOutputFormatter.cs
Normal file
28
PartSource.Api/Formatters/LiquidTemplateOutputFormatter.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user