Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/apiutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ proc fetchRaw*(req: ApiReq): Future[string] {.async.} =
var session = await getAndValidateSession(req)
let url = req.toUrl(session.kind)

echo "fetchRaw url: ", url

fetchImpl result:
echo "fetchRaw result: ", result
if not (result.startsWith('{') or result.startsWith('[')):
echo resp.status, ": ", result, " --- url: ", url
result.setLen(0)
3 changes: 3 additions & 0 deletions src/http_pool.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ proc setHttpProxy*(url: string; auth: string) =
else:
proxy = nil

proc getHttpProxy*(): Proxy =
return proxy

proc release*(pool: HttpPool; client: AsyncHttpClient; badClient=false) =
if pool.conns.len >= maxConns or badClient:
try: client.close()
Expand Down
3 changes: 3 additions & 0 deletions src/redis_cache.nim
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ proc getCachedUsername*(userId: string): Future[string] {.async.} =
if username != redisNil:
result = username
else:
echo "getGraphUserById: ", userId
let user = await getGraphUserById(userId)
echo "user: ", user

result = user.username
await setEx(key, baseCacheTime, result)
if result.len > 0 and user.id.len > 0:
Expand Down
3 changes: 2 additions & 1 deletion src/tid.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import std/[asyncdispatch, base64, httpclient, random, strutils, sequtils, times]
import nimcrypto
import experimental/parser/tid
import http_pool

randomize()

Expand All @@ -18,7 +19,7 @@ proc getPair(): Future[TidPair] {.async.} =
if cachedPairs.len == 0 or int(epochTime()) - lastCached > ttlSec:
lastCached = int(epochTime())

let client = newAsyncHttpClient()
let client = newAsyncHttpClient(proxy=getHttpProxy())
defer: client.close()

let resp = await client.get(pairsUrl)
Expand Down
Loading