Set correct content-type for JSON-RPC
This commit is contained in:
parent
34b7a82565
commit
0b951ce146
|
@ -50,14 +50,17 @@ template convertError(body) =
|
||||||
|
|
||||||
const defaultUrl = "http://localhost:8545"
|
const defaultUrl = "http://localhost:8545"
|
||||||
|
|
||||||
|
proc jsonHeaders: seq[(string, string)] =
|
||||||
|
@[("Content-Type", "application/json")]
|
||||||
|
|
||||||
proc connect(_: type RpcClient, url: string): Future[RpcClient] {.async.} =
|
proc connect(_: type RpcClient, url: string): Future[RpcClient] {.async.} =
|
||||||
case parseUri(url).scheme
|
case parseUri(url).scheme
|
||||||
of "ws", "wss":
|
of "ws", "wss":
|
||||||
let client = newRpcWebSocketClient()
|
let client = newRpcWebSocketClient(getHeaders = jsonHeaders)
|
||||||
await client.connect(url)
|
await client.connect(url)
|
||||||
return client
|
return client
|
||||||
else:
|
else:
|
||||||
let client = newRpcHttpClient()
|
let client = newRpcHttpClient(getHeaders = jsonHeaders)
|
||||||
await client.connect(url)
|
await client.connect(url)
|
||||||
return client
|
return client
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue