all repos — min @ ecd4ef1c31b2bec6e6f85e39cb1344eb9fb87c2d

A small but practical concatenative programming language.

Fixed start-server; updated example.
h3rald h3rald@h3rald.com
Fri, 10 Jan 2020 15:05:25 +0100
commit

ecd4ef1c31b2bec6e6f85e39cb1344eb9fb87c2d

parent

5a62e58e181baa9b3d6ee4b4d01dc1bc6b75e3c0

2 files changed, 10 insertions(+), 9 deletions(-)

jump to
M lib/min_http.nimlib/min_http.nim

@@ -96,7 +96,7 @@ i.push qreq

i.dequote qhandler let qres = i.pop var body = "".newVal - var rawHeaders = newSeq[MinValue]().newVal + var rawHeaders = newDict(i.scope) var v = "1.1" var status = 200.newVal if not qres.isDictionary():

@@ -116,8 +116,8 @@ rawHeaders = i.dget(qres, "headers")

if not rawHeaders.isDictionary(): raiseInvalid("Response headers are not in a dictionary.") var headers = newHttpHeaders() - for v in rawHeaders.qVal: - headers[v.qVal[0].getString] = v.qVal[1].getString + for k in items(i.keys(rawHeaders).qVal): + headers[k.getString] = i.dget(rawHeaders, k.getString).getString await req.respond(status.intVal.HttpCode, body.getString, headers) try: waitFor server.serve(port = port.intVal.Port, callback = handler, address = address.getString)
M site/contents/reference-http.mdsite/contents/reference-http.md

@@ -57,16 +57,17 @@ > > "Stopping server..." puts!

> > stop-server > > ) when > > ;Prepare response -> > {body :body} +> > {} body %body > > ) =handler -> > +> > > > ;Start server > > "Server started on port 5555." puts! > > "Press Ctrl+C to stop." puts! -> > { -> > handler :handler -> > 5555 :port -> > } tap start-server +> > +> > {} +> > handler %handler +> > 5555 %port +> > start-server #} {#op||stop-server||{{null}}||{{null}}||