diff options
Diffstat (limited to 'src/MessagePack.AspNetCoreMvcFormatter/MessagePackInputFormatter.cs')
-rw-r--r-- | src/MessagePack.AspNetCoreMvcFormatter/MessagePackInputFormatter.cs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/MessagePack.AspNetCoreMvcFormatter/MessagePackInputFormatter.cs b/src/MessagePack.AspNetCoreMvcFormatter/MessagePackInputFormatter.cs index 95edae0e..59c49a99 100644 --- a/src/MessagePack.AspNetCoreMvcFormatter/MessagePackInputFormatter.cs +++ b/src/MessagePack.AspNetCoreMvcFormatter/MessagePackInputFormatter.cs @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Mvc.Formatters; namespace MessagePack.AspNetCoreMvcFormatter { - public class MessagePackInputFormatter : IInputFormatter + public class MessagePackInputFormatter : InputFormatter { private const string ContentType = "application/x-msgpack"; private readonly MessagePackSerializerOptions options; @@ -19,12 +19,11 @@ namespace MessagePack.AspNetCoreMvcFormatter public MessagePackInputFormatter(MessagePackSerializerOptions options) { this.options = options; - } - public bool CanRead(InputFormatterContext context) => - context.HttpContext.Request.ContentType == ContentType; + SupportedMediaTypes.Add(ContentType); + } - public async Task<InputFormatterResult> ReadAsync(InputFormatterContext context) + public override async Task<InputFormatterResult> ReadRequestBodyAsync(InputFormatterContext context) { var request = context.HttpContext.Request; var result = await MessagePackSerializer.DeserializeAsync(context.ModelType, request.Body, this.options, context.HttpContext.RequestAborted).ConfigureAwait(false); |