Skip to content

Commit

Permalink
Merge pull request #47 from status-im/request-header-callback
Browse files Browse the repository at this point in the history
request header callback
  • Loading branch information
tersec committed Mar 14, 2022
2 parents 91c998a + abf5a27 commit 58b2e07
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions web3.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 58b2e07

Please sign in to comment.