Set correct content-type for JSON-RPC

This commit is contained in:
Mark Spanbroek 2023-06-20 13:32:14 +02:00 committed by markspanbroek
parent 34b7a82565
commit 0b951ce146
1 changed files with 5 additions and 2 deletions

View File

@ -50,14 +50,17 @@ template convertError(body) =
const defaultUrl = "http://localhost:8545"
proc jsonHeaders: seq[(string, string)] =
@[("Content-Type", "application/json")]
proc connect(_: type RpcClient, url: string): Future[RpcClient] {.async.} =
case parseUri(url).scheme
of "ws", "wss":
let client = newRpcWebSocketClient()
let client = newRpcWebSocketClient(getHeaders = jsonHeaders)
await client.connect(url)
return client
else:
let client = newRpcHttpClient()
let client = newRpcHttpClient(getHeaders = jsonHeaders)
await client.connect(url)
return client