Skip to content

Instantly share code, notes, and snippets.

@enthus1ast
Created October 28, 2017 16:15
Show Gist options
  • Save enthus1ast/f878e3ec23cb9d267ca2b3439ea2bc90 to your computer and use it in GitHub Desktop.
Save enthus1ast/f878e3ec23cb9d267ca2b3439ea2bc90 to your computer and use it in GitHub Desktop.
import asyncdispatch, asynchttpserver
type SomeObj = object
someData: string
proc manageUiCallback(req: Request): Future[void] {.async.} =
var res = ""
# This callback wants to access someObj somehow!
res.add someObj.someData
await req.respond(Http200, res)
var someObj = SomeObj(someData: "foo")
var server = newAsyncHttpServer()
waitFor server.serve(Port(8080), manageUiCallback)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment