Guest User

Untitled

a guest
Feb 7th, 2020
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 1.41 KB | None | 0 0
  1. import asynchttpserver, asyncdispatch, strutils, os, tables
  2.  
  3. var fileTable = initTable[string, string]()
  4.  
  5. proc getFileCont(path: string): string =
  6.   let f = fileTable.hasKey(path)
  7.   "sdflkj"
  8.  
  9. proc serveStatic*(req: Request) {.async.} =
  10.   await req.respond(Http200, getFileCont(req.url.path))
  11.  
  12. # error
  13.         ... C:\Users\sveri\IdeaProjects\nim\nosp\src\nosppkg\async_server.nim(12, 17) template/generic instantiation of `async` from here
  14.         ... C:\Users\sveri\IdeaProjects\nim\nosp\src\nosppkg\async_server.nim(18, 17) Error: type mismatch: got <AsyncHttpServer, Port, proc (req: Request): Future[system.void]{.locks: <unknown>.}>
  15.         ... but expected one of:
  16.         ... proc serve(server: AsyncHttpServer; port: Port;
  17.         ...           callback: proc (request: Request): Future[void] {.closure, gcsafe.};
  18.         ...           address = ""): owned(Future[void])
  19.         ...   first type mismatch at position: 3
  20.         ...   required type for callback: proc (request: Request): Future[system.void]{.closure, gcsafe.}
  21.         ...   but expression 'cb' is of type: proc (req: Request): Future[system.void]{.locks: <unknown>.}
  22.         ...   This expression is not GC-safe. Annotate the proc with {.gcsafe.} to get extended error information.
  23.         ... 1 other mismatching symbols have been suppressed; compile with --showAllMismatches:on to see them
  24.         ... expression: serve(server, Port(5000), cb)
Advertisement
Add Comment
Please, Sign In to add comment