I am not familiar at all about `async`. I am trying to reuse the following 
code: 
    
    
    import asynchttpserver, asyncdispatch
    
    proc main {.async.} =
      var server = newAsyncHttpServer()
      proc cb(req: Request) {.async.} =
        let headers = {"Date": "Tue, 29 Apr 2014 23:40:08 GMT",
            "Content-type": "text/plain; charset=utf-8"}
        await req.respond(Http200, "Hello World", headers.newHttpHeaders())
      
      server.listen Port(8080)
      while true:
        if server.shouldAcceptRequest():
          asyncCheck server.acceptRequest(cb)
        else:
          poll()
    
    asyncCheck main()
    runForever()
    
    
    Run

What I want is to create a server in the middle of the code and wait for 
request and stop it once I received the call. So it feels like I need the 
`synced` version (I not that familiar with sync/async stuff; I mostly do synced 
coding).

How can I convert the code above for that purpose?

Reply via email to