well, as i've already written, i would not use globals to store sessions. I
would create a session object that holds all your data and pass it to every
procedure.
so feed the session table into your http callback:
import asynchttpserver, asyncdispatch, tables
type
Session = ref object
## your stuff
Sessions = Table[string, Session]
proc cb(req: Request, sessions: Sessions) {.async.} =
## do stuff
echo sessions.len
proc main() =
let server = newAsyncHttpServer()
var sessions: Table[string, Session]
# ...
waitFor server.serve(
Port(8080),
proc (req: Request): Future[void] = cb(req, sessions)
)
main()
Run