treturn_await.nim 558 B

123456789101112131415161718192021222324
  1. # bug #4371
  2. import strutils, asyncdispatch, asynchttpserver
  3. type
  4. List[A] = ref object
  5. value: A
  6. next: List[A]
  7. StrPair* = tuple[k, v: string]
  8. Context* = object
  9. position*: int
  10. accept*: bool
  11. headers*: List[StrPair]
  12. Handler* = proc(req: ref Request, ctx: Context): Future[Context]
  13. proc logging*(handler: Handler): auto =
  14. proc h(req: ref Request, ctx: Context): Future[Context] {.async.} =
  15. let ret = handler(req, ctx)
  16. debugEcho "$3 $1 $2".format(req.reqMethod, req.url.path, req.hostname)
  17. return await ret
  18. return h