So I've got some code like this: import asyncDispatch import asynchttpserver # Create the server object and state data var server = newAsyncHttpServer() let port = 8000 # ... proc handleRequest(req: Request) {.async.}= ## Handle an incomming connection var killServer = false # ... if killServer: server.close() # Write a response var headers = newHttpHeaders() headers.add("Content-Type", "text/html") await req.respond(Http200, mkPage(pageViews, killServer), headers) # Handle requests echo("Listening for connections on http://localhost:" & $port & "/") waitFor server.serve(Port(port), handleRequest)
If I try to call server.close() I keep on getting this error: Server.nim(74, 15) Error: type mismatch: got (AsyncHttpServer, Port, proc (req: Request): Future[system.void]{.locks: <unknown>.}) but expected one of: proc serve(server: AsyncHttpServer; port: Port; callback: proc (request: Request): Future[void]; address = ""): Future[void] I've tried creating a wrapper async function around the close call, that didn't work. I tried using an event callback, that didn't work either. Both other produced the same compilation errors. What's going on here?