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:
parent
fb88309b34
commit
cf06c4e87e
|
@ -66,7 +66,9 @@ template init(T: type RpcHttpServer, ip: ValidIpAddress, port: Port): T =
|
||||||
|
|
||||||
template init(T: type RestServerRef, ip: ValidIpAddress, port: Port): T =
|
template init(T: type RestServerRef, ip: ValidIpAddress, port: Port): T =
|
||||||
let address = initTAddress(ip, port)
|
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():
|
if res.isErr():
|
||||||
notice "Rest server could not be started", address = $address,
|
notice "Rest server could not be started", address = $address,
|
||||||
reason = res.error()
|
reason = res.error()
|
||||||
|
|
|
@ -23,8 +23,8 @@ proc jsonResponseWRoot*(t: typedesc[RestApiResponse],
|
||||||
writer.writeField("dependent_root", dependent_root)
|
writer.writeField("dependent_root", dependent_root)
|
||||||
writer.writeField("data", data)
|
writer.writeField("data", data)
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
ok(ContentBody(contentType: "application/json",
|
RestApiResponse.response(stream.getOutput(seq[byte]), Http200,
|
||||||
data: stream.getOutput(seq[byte])))
|
"application/json")
|
||||||
|
|
||||||
proc jsonResponse*(t: typedesc[RestApiResponse],
|
proc jsonResponse*(t: typedesc[RestApiResponse],
|
||||||
data: auto): RestApiResponse =
|
data: auto): RestApiResponse =
|
||||||
|
@ -33,8 +33,8 @@ proc jsonResponse*(t: typedesc[RestApiResponse],
|
||||||
writer.beginRecord()
|
writer.beginRecord()
|
||||||
writer.writeField("data", data)
|
writer.writeField("data", data)
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
ok(ContentBody(contentType: "application/json",
|
RestApiResponse.response(stream.getOutput(seq[byte]), Http200,
|
||||||
data: stream.getOutput(seq[byte])))
|
"application/json")
|
||||||
|
|
||||||
proc jsonResponseWMeta*(t: typedesc[RestApiResponse],
|
proc jsonResponseWMeta*(t: typedesc[RestApiResponse],
|
||||||
data: auto, meta: auto): RestApiResponse =
|
data: auto, meta: auto): RestApiResponse =
|
||||||
|
@ -44,8 +44,8 @@ proc jsonResponseWMeta*(t: typedesc[RestApiResponse],
|
||||||
writer.writeField("data", data)
|
writer.writeField("data", data)
|
||||||
writer.writeField("meta", meta)
|
writer.writeField("meta", meta)
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
ok(ContentBody(contentType: "application/json",
|
RestApiResponse.response(stream.getOutput(seq[byte]), Http200,
|
||||||
data: stream.getOutput(seq[byte])))
|
"application/json")
|
||||||
|
|
||||||
proc jsonError*(t: typedesc[RestApiResponse], status: HttpCode = Http200,
|
proc jsonError*(t: typedesc[RestApiResponse], status: HttpCode = Http200,
|
||||||
msg: string = "", stacktrace: string = ""): RestApiResponse =
|
msg: string = "", stacktrace: string = ""): RestApiResponse =
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit c15c985c1fa1c58abfeba7ba46393f9238a2fd84
|
Subproject commit 7ccb170f7a0d02d724af03b4fce9c270c41125cb
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8943d3fd6c2e5be1c604a0afdc2b873ad3575bd1
|
Subproject commit 5163805723deeec11a25004422e9b17922aaa855
|
Loading…
Reference in New Issue