Hello everyone! I'm trying to use the => macro from std/sugar like so (example is from a project using prologue):
app.addRoute("/{path}$", (ctx) {.async.} => getPage(ctx, config), HttpGet)
addRoute expects an async proc, hence the {.async.} pragma. The problem is that this fails to compile with the error Expected return type of 'Future' got 'auto' Now if explicitly define the proc like so, it works.
proc pageHandler(ctx: Context) {.async.} =
getPage(ctx, config)
So is there a way to explicitly set the return type to Future[void] when using =>?
Thanks!
Try this
(ctx) {.async.} -> Future[void] => getPage(ctx, config)
Thanks! That almost worked, I had to modify to this:
(ctx: Context) {.async.} -> Future[void] => await getPage(ctx)
I assume I could create a PR to update the documentation?