WIP Adding GET /project/<projectName> endpoint.

This commit is contained in:
Jonathan Bernard
2017-11-20 10:05:55 -06:00
parent 6340b2fa49
commit f222d859e6
3 changed files with 38 additions and 13 deletions

View File

@ -98,14 +98,13 @@ proc raiseEx*(reason: string): void =
raise newException(Exception, reason)
# internal utils
let nullNode = newJNull()
proc getIfExists(n: JsonNode, key: string): JsonNode =
# convenience method to get a key from a JObject or return null
## convenience method to get a key from a JObject or return null
result = if n.hasKey(key): n[key]
else: nullNode
else: newJNull()
proc getOrFail(n: JsonNode, key: string, objName: string = ""): JsonNode =
# convenience method to get a key from a JObject or raise an exception
## convenience method to get a key from a JObject or raise an exception
if not n.hasKey(key): raiseEx objName & " missing key '" & key & "'"
return n[key]