Merge pull request #47 from status-im/request-header-callback
request header callback
This commit is contained in:
commit
58b2e07830
8
web3.nim
8
web3.nim
|
@ -68,16 +68,18 @@ proc newWeb3*(provider: RpcClient): Web3 =
|
|||
provider.setMethodHandler("eth_subscription") do(j: JsonNode):
|
||||
r.handleSubscriptionNotification(j)
|
||||
|
||||
proc newWeb3*(uri: string): Future[Web3] {.async.} =
|
||||
proc newWeb3*(
|
||||
uri: string, getHeaders: GetJsonRpcRequestHeaders = nil):
|
||||
Future[Web3] {.async.} =
|
||||
let u = parseUri(uri)
|
||||
var provider: RpcClient
|
||||
case u.scheme
|
||||
of "http", "https":
|
||||
let p = newRpcHttpClient()
|
||||
let p = newRpcHttpClient(getHeaders = getHeaders)
|
||||
await p.connect(uri)
|
||||
provider = p
|
||||
of "ws", "wss":
|
||||
let p = newRpcWebSocketClient()
|
||||
let p = newRpcWebSocketClient(getHeaders = getHeaders)
|
||||
await p.connect(uri)
|
||||
provider = p
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue