Skip to content

Commit 33593b6

Browse files
committed
New line character added to JSON response
1 parent 7139715 commit 33593b6

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

src/Nethermind/Nethermind.DataMarketplace.Consumers.Infrastructure/NdmConsumersModule.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Copyright (c) 2018 Demerzel Solutions Limited
3+
* This file is part of the Nethermind library.
4+
*
5+
* The Nethermind library is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* The Nethermind library is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with the Nethermind. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
119
using Nethermind.DataMarketplace.Consumers.Infrastructure.Persistence.Mongo.Repositories;
220
/*
321
* Copyright (c) 2018 Demerzel Solutions Limited

src/Nethermind/Nethermind.Runner/Controllers/MainController.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using System.Linq;
2121
using System.Text;
2222
using System.Threading.Tasks;
23+
using Microsoft.AspNetCore.Http;
2324
using Microsoft.AspNetCore.Mvc;
2425
using Nethermind.JsonRpc;
2526
using Newtonsoft.Json;
@@ -31,7 +32,6 @@ namespace Nethermind.Runner.Controllers
3132
[ApiController]
3233
public class MainController : ControllerBase
3334
{
34-
3535
private readonly IJsonRpcProcessor _jsonRpcProcessor;
3636
private readonly JsonSerializerSettings _jsonSettings;
3737

@@ -40,6 +40,7 @@ public MainController(IJsonRpcProcessor jsonRpcProcessor, IJsonRpcService jsonRp
4040
_jsonRpcProcessor = jsonRpcProcessor;
4141
_jsonSettings = new JsonSerializerSettings
4242
{
43+
Formatting = Formatting.Indented,
4344
ContractResolver = new CamelCasePropertyNamesContractResolver()
4445
};
4546

@@ -53,14 +54,15 @@ public MainController(IJsonRpcProcessor jsonRpcProcessor, IJsonRpcService jsonRp
5354
public ActionResult<string> Get() => "Nethermind JSON RPC";
5455

5556
[HttpPost]
56-
public async Task<JsonResult> Post()
57+
public async Task Post()
5758
{
5859
using (var reader = new StreamReader(Request.Body, Encoding.UTF8))
5960
{
6061
var result = await _jsonRpcProcessor.ProcessAsync(await reader.ReadToEndAsync());
61-
return result.IsCollection
62-
? new JsonResult(result.Responses, _jsonSettings)
63-
: new JsonResult(result.Responses.SingleOrDefault(), _jsonSettings);
62+
var json = result.IsCollection
63+
? JsonConvert.SerializeObject(result.Responses, _jsonSettings)
64+
: JsonConvert.SerializeObject(result.Responses.SingleOrDefault(), _jsonSettings);
65+
await Response.WriteAsync($"{json}\n");
6466
}
6567
}
6668
}

0 commit comments

Comments
 (0)