Modified example to properly manage OPTIONS and HEAD.
h3rald h3rald@h3rald.com
Fri, 13 Oct 2017 21:28:22 +0200
1 files changed,
11 insertions(+),
3 deletions(-)
jump to
M
examples/jester_integration.nim
→
examples/jester_integration.nim
@@ -1,4 +1,4 @@
-import jester, ../litestore, asyncdispatch, re +import jester, ../litestore, asyncdispatch, re, strtabs, asyncnet litestore.setup()@@ -31,10 +31,18 @@ resp(r.code, r.content)
head re"^\/litestore\/docs\/?(.*)": let r = head("docs", request.matches[0], request.headers) - resp(r.code, r.content) + headers = newStringTable() + for key, value in r.headers.pairs: + headers[key] = value + await response.sendHeaders(r.code, headers) + response.client.close() options re"^\/litestore\/docs\/?(.*)": let r = options("docs", request.matches[0], request.headers) - resp(r.code, r.content) + headers = newStringTable() + for key, value in r.headers.pairs: + headers[key] = value + await response.sendHeaders(r.code, headers) + response.client.close() runForever()