From dc31d590a0c0694509271bc57e23ba0bd25d631f Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Mon, 1 Oct 2018 11:22:48 -0400 Subject: [PATCH] Add GET /issue/ API endpoint. --- src/pit_api.nim | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pit_api.nim b/src/pit_api.nim index 58769c9..af735dd 100644 --- a/src/pit_api.nim +++ b/src/pit_api.nim @@ -94,6 +94,19 @@ proc start*(cfg: PitApiCfg) = post "/issues": checkAuth(cfg); if not authed: return true + get "/issue/@issueId": + checkAuth(cfg); if not authed: return true + + var (hasColor, args) = paramsToArgs(request.params) + args = @["list", issueId] & args + + info "args: \n" & args.join(" ") + let execResult = execWithOutput("pit", ".", args) + if execResult[2] != 0: resp(Http500, stripAnsi($execResult[0] & "\n" & $execResult[1]), TXT) + else: + if hasColor: resp(stripAnsi(execResult[0]), TXT) + else: resp(execResult[0], TXT) + waitFor(stopFuture) proc loadApiConfig(args: Table[string, Value]): PitApiCfg =