Make REST server more compatible with Lighthouse and Teku validator clients. (#2575)

* Allow REST server to parse arrays with comma delimiter.

* Fix compilation issues because of new presto framework.
This commit is contained in:
Eugene Kabanov 2021-05-18 13:24:57 +03:00 committed by GitHub
parent fb88309b34
commit cf06c4e87e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 9 deletions

View File

@ -66,7 +66,9 @@ template init(T: type RpcHttpServer, ip: ValidIpAddress, port: Port): T =
template init(T: type RestServerRef, ip: ValidIpAddress, port: Port): T =
let address = initTAddress(ip, port)
let res = RestServerRef.new(getRouter(), address)
let serverFlags = {HttpServerFlags.QueryCommaSeparatedArray,
HttpServerFlags.NotifyDisconnect}
let res = RestServerRef.new(getRouter(), address, serverFlags = serverFlags)
if res.isErr():
notice "Rest server could not be started", address = $address,
reason = res.error()

View File

@ -23,8 +23,8 @@ proc jsonResponseWRoot*(t: typedesc[RestApiResponse],
writer.writeField("dependent_root", dependent_root)
writer.writeField("data", data)
writer.endRecord()
ok(ContentBody(contentType: "application/json",
data: stream.getOutput(seq[byte])))
RestApiResponse.response(stream.getOutput(seq[byte]), Http200,
"application/json")
proc jsonResponse*(t: typedesc[RestApiResponse],
data: auto): RestApiResponse =
@ -33,8 +33,8 @@ proc jsonResponse*(t: typedesc[RestApiResponse],
writer.beginRecord()
writer.writeField("data", data)
writer.endRecord()
ok(ContentBody(contentType: "application/json",
data: stream.getOutput(seq[byte])))
RestApiResponse.response(stream.getOutput(seq[byte]), Http200,
"application/json")
proc jsonResponseWMeta*(t: typedesc[RestApiResponse],
data: auto, meta: auto): RestApiResponse =
@ -44,8 +44,8 @@ proc jsonResponseWMeta*(t: typedesc[RestApiResponse],
writer.writeField("data", data)
writer.writeField("meta", meta)
writer.endRecord()
ok(ContentBody(contentType: "application/json",
data: stream.getOutput(seq[byte])))
RestApiResponse.response(stream.getOutput(seq[byte]), Http200,
"application/json")
proc jsonError*(t: typedesc[RestApiResponse], status: HttpCode = Http200,
msg: string = "", stacktrace: string = ""): RestApiResponse =

2
vendor/nim-chronos vendored

@ -1 +1 @@
Subproject commit c15c985c1fa1c58abfeba7ba46393f9238a2fd84
Subproject commit 7ccb170f7a0d02d724af03b4fce9c270c41125cb

2
vendor/nim-presto vendored

@ -1 +1 @@
Subproject commit 8943d3fd6c2e5be1c604a0afdc2b873ad3575bd1
Subproject commit 5163805723deeec11a25004422e9b17922aaa855