Add one more version of `new(RestClientRef)` which accepts HttpAddress. (#57)

This commit is contained in:
Eugene Kabanov 2023-09-04 16:10:21 +03:00 committed by GitHub
parent a30fcd4c29
commit eee1f7ad04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 0 deletions

View File

@ -156,6 +156,26 @@ proc new*(t: typedesc[RestClientRef],
ok(RestClientRef(session: session, address: address, agent: userAgent, ok(RestClientRef(session: session, address: address, agent: userAgent,
flags: flags)) flags: flags))
proc new*(t: typedesc[RestClientRef],
address: HttpAddress,
flags: RestClientFlags = {},
httpFlags: HttpClientFlags = {},
maxConnections: int = -1,
maxRedirections: int = HttpMaxRedirections,
connectTimeout = HttpConnectTimeout,
headersTimeout = HttpHeadersTimeout,
idleTimeout = HttpConnectionIdleTimeout,
idlePeriod = HttpConnectionCheckPeriod,
bufferSize: int = 4096,
userAgent = PrestoIdent,
socketFlags: set[SocketFlags] = {}
): RestResult[RestClientRef] =
let session = HttpSessionRef.new(httpFlags, maxRedirections, connectTimeout,
headersTimeout, bufferSize, maxConnections,
idleTimeout, idlePeriod, socketFlags)
ok(RestClientRef(session: session, address: address, agent: userAgent,
flags: flags))
proc new*(t: typedesc[RestClientRef], proc new*(t: typedesc[RestClientRef],
ta: TransportAddress, ta: TransportAddress,
scheme: HttpClientScheme = HttpClientScheme.NonSecure, scheme: HttpClientScheme = HttpClientScheme.NonSecure,