WIP Adding GET /project/<projectName> endpoint.
This commit is contained in:
@ -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]
|
||||
|
||||
|
Reference in New Issue
Block a user