|
|
|
|
|
by Nycto
3645 days ago
|
|
I came here to say the same thing as the GP. So while I am not the poster you responded to, I'll pitch in my opinion. I've written a number of Nim libs at this point. Rosencrantz is missing the idiomatic 'feel' of Nim -- blocks and trees. I would rather see a syntax like this: let handler = firstOf:
get:
firstOf:
path("/api/status"):
ok(getStatus())
pathChunk("/api/message"):
accept("application/json"):
intSegment(id):
let message = getMessageById(id)
ok(message)
post:
path("/api/new-message"):
jsonBody(msg):
let
id = generateId()
saved = saveMessage(id, msg)
if saved: ok(id)
else: complete(Http500, "save failed")
I believe all of that should be possible using templates; grab the AST for the `stmt` passed to each function, then iterate over each node. |
|
Templates would allow for the syntax you present, but do not combine.