mirror of
https://github.com/logos-storage/nim-json-rpc.git
synced 2026-01-08 08:33:14 +00:00
httpserver.nim: adding 'Content-Type: application/json' header to the response (#165)
This commit is contained in:
parent
4c31a8bd46
commit
0bf2bcbe74
@ -41,14 +41,19 @@ proc processClientRpc(rpcServer: RpcHttpServer): HttpProcessCallback =
|
||||
|
||||
let body = await request.getBody()
|
||||
|
||||
let headers = HttpTable.init([("Content-Type",
|
||||
"application/json; charset=utf-8")])
|
||||
|
||||
let future = rpcServer.route(string.fromBytes(body))
|
||||
yield future
|
||||
if future.failed:
|
||||
debug "Internal error while processing JSON-RPC call"
|
||||
return await request.respond(Http503, "Internal error while processing JSON-RPC call")
|
||||
return await request.respond(Http503,
|
||||
"Internal error while processing JSON-RPC call",
|
||||
headers)
|
||||
else:
|
||||
var data = future.read()
|
||||
let res = await request.respond(Http200, data)
|
||||
let res = await request.respond(Http200, data, headers)
|
||||
trace "JSON-RPC result has been sent"
|
||||
return res
|
||||
else:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user