Add authhooks to proxy constructor (#153)
This commit is contained in:
parent
5fa7071d5b
commit
64dbf122d7
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue