fix protobuf

This commit is contained in:
Kukks 2024-07-26 15:42:34 +02:00
parent 5ea1af44d3
commit a6c01f4658
No known key found for this signature in database
GPG key ID: 8E5530D9D1C93097
3 changed files with 22 additions and 2 deletions

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Google.Protobuf;
@ -8,8 +9,24 @@ namespace BTCPayServer.App.API;
public class ProtobufInputFormatter : InputFormatter
{
public ProtobufInputFormatter()
{
SupportedMediaTypes.Add("application/octet-stream");
}
public override async Task<InputFormatterResult> ReadRequestBodyAsync(InputFormatterContext context)
{
throw new NotImplementedException();
}
public override bool CanRead(InputFormatterContext context)
{
return base.CanRead(context);
}
public override async Task<InputFormatterResult> ReadAsync(InputFormatterContext context)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));

View file

@ -9,6 +9,10 @@ namespace BTCPayServer.App.API;
public class ProtobufOutputFormatter : OutputFormatter
{
public ProtobufOutputFormatter()
{
SupportedMediaTypes.Add("application/octet-stream");
}
public override async Task WriteResponseBodyAsync(OutputFormatterWriteContext context)
{
if (context == null)
@ -40,4 +44,4 @@ public class ProtobufOutputFormatter : OutputFormatter
await stream.CopyToAsync(response.Body);
}
}
}
}

View file

@ -15,7 +15,6 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using NBitcoin.Crypto;
using VSSProto;
namespace BTCPayServer.App.API;