diff --git a/json_rpc/rpcproxy.nim b/json_rpc/rpcproxy.nim index f4a03bd..12395d7 100644 --- a/json_rpc/rpcproxy.nim +++ b/json_rpc/rpcproxy.nim @@ -48,7 +48,7 @@ proc proxyCall(client: RpcClient, name: string): RpcProc = let res = await client.call(name, params) return StringOfJson($res) -proc getClient(proxy: RpcProxy): RpcClient = +proc getClient*(proxy: RpcProxy): RpcClient = case proxy.kind of Http: proxy.httpClient @@ -71,11 +71,20 @@ proc new*(T: type RpcProxy, server: RpcHttpServer, cfg: ClientConfig): T = flags: cfg.flags ) -proc new*(T: type RpcProxy, listenAddresses: openArray[TransportAddress], cfg: ClientConfig): T {.raises: [Defect, CatchableError].} = - RpcProxy.new(newRpcHttpServer(listenAddresses, RpcRouter.init()), cfg) +proc new*( + T: type RpcProxy, + listenAddresses: openArray[TransportAddress], + cfg: ClientConfig, + authHooks: seq[HttpAuthHook] = @[] +): T {.raises: [Defect, CatchableError].} = + RpcProxy.new(newRpcHttpServer(listenAddresses, RpcRouter.init(), authHooks), cfg) -proc new*(T: type RpcProxy, listenAddresses: openArray[string], cfg: ClientConfig): T {.raises: [Defect, CatchableError].} = - RpcProxy.new(newRpcHttpServer(listenAddresses, RpcRouter.init()), cfg) +proc new*( + T: type RpcProxy, + listenAddresses: openArray[string], + cfg: ClientConfig, + authHooks: seq[HttpAuthHook] = @[]): T {.raises: [Defect, CatchableError].} = + RpcProxy.new(newRpcHttpServer(listenAddresses, RpcRouter.init(), authHooks), cfg) proc connectToProxy(proxy: RpcProxy): Future[void] = case proxy.kind