diff options
author | flywind <43030857+xflywind@users.noreply.github.com> | 2021-01-11 11:02:32 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-11 18:02:32 +0100 |
commit | 5af13c5aceaedf211ff59113384bcb6a85c35c2b (patch) | |
tree | c4d022d8cd14e6113364d0281c5216ba624acac4 /tests/ccgbugs/t9655.nim | |
parent | 0c128259bb01cde8ed27430929b0a01c5ee7b88c (diff) | |
download | Nim-5af13c5aceaedf211ff59113384bcb6a85c35c2b.tar.gz |
close #9655 add testcase (#16683)
Diffstat (limited to 'tests/ccgbugs/t9655.nim')
-rw-r--r-- | tests/ccgbugs/t9655.nim | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/ccgbugs/t9655.nim b/tests/ccgbugs/t9655.nim new file mode 100644 index 000000000..29fb903a4 --- /dev/null +++ b/tests/ccgbugs/t9655.nim @@ -0,0 +1,30 @@ +discard """ + action: "compile" +""" + +import std/[asynchttpserver, asyncdispatch] +import std/[strformat] + +proc main() = + let local = "123" + + proc serveIndex(req: Request) {.async, gcsafe.} = + await req.respond(Http200, &"{local}") + + proc serve404(req: Request) {.async, gcsafe.} = + echo req.url.path + await req.respond(Http404, "not found") + + proc serve(req: Request) {.async, gcsafe.} = + let handler = case req.url.path: + of "/": + serveIndex + else: + serve404 + await handler(req) + + let server = newAsyncHttpServer() + waitFor server.serve(Port(8080), serve, address = "127.0.0.1") + +when isMainModule: + main() |