WIP Updates to compile on Nim 0.19.
This commit is contained in:
parent
93a0a15f12
commit
f8ccc831ef
@ -11,5 +11,5 @@ bin = @["pit", "pit_api"]
|
|||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
||||||
requires @[ "nim >= 0.18.0", "cliutils 0.5.0", "docopt 0.6.5", "jester 0.2.0",
|
requires @[ "nim >= 0.19.0", "cliutils 0.6.0", "docopt 0.6.8", "jester 0.4.1",
|
||||||
"langutils >= 0.4.0", "timeutils 0.3.0", "uuids 0.1.9" ]
|
"langutils >= 0.4.0", "timeutils 0.3.0", "uuids 0.1.10" ]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
## Personal Issue Tracker API Interface
|
## Personal Issue Tracker API Interface
|
||||||
## ====================================
|
## ====================================
|
||||||
|
|
||||||
import asyncdispatch, cliutils, docopt, jester, json, logging, sequtils, strutils
|
import asyncdispatch, cliutils, docopt, jester, json, logging, options, sequtils, strutils
|
||||||
import nre except toSeq
|
import nre except toSeq
|
||||||
|
|
||||||
import pitpkg/private/libpit
|
import pitpkg/private/libpit
|
||||||
@ -18,6 +18,20 @@ const TXT = "text/plain"
|
|||||||
|
|
||||||
proc raiseEx(reason: string): void = raise newException(Exception, reason)
|
proc raiseEx(reason: string): void = raise newException(Exception, reason)
|
||||||
|
|
||||||
|
template halt(code: HttpCode,
|
||||||
|
headers: RawHeaders,
|
||||||
|
content: string): typed =
|
||||||
|
## Immediately replies with the specified request. This means any further
|
||||||
|
## code will not be executed after calling this template in the current
|
||||||
|
## route.
|
||||||
|
bind TCActionSend, newHttpHeaders
|
||||||
|
result[0] = CallbackAction.TCActionSend
|
||||||
|
result[1] = code
|
||||||
|
result[2] = some(headers)
|
||||||
|
result[3] = content
|
||||||
|
result.matched = true
|
||||||
|
break allRoutes
|
||||||
|
|
||||||
template checkAuth(cfg: PitApiCfg) =
|
template checkAuth(cfg: PitApiCfg) =
|
||||||
## Check this request for authentication and authorization information.
|
## Check this request for authentication and authorization information.
|
||||||
## If the request is not authorized, this template sets up the 401 response
|
## If the request is not authorized, this template sets up the 401 response
|
||||||
@ -40,11 +54,10 @@ template checkAuth(cfg: PitApiCfg) =
|
|||||||
|
|
||||||
except:
|
except:
|
||||||
stderr.writeLine "Auth failed: " & getCurrentExceptionMsg()
|
stderr.writeLine "Auth failed: " & getCurrentExceptionMsg()
|
||||||
response.data[0] = CallbackAction.TCActionSend
|
halt(
|
||||||
response.data[1] = Http401
|
Http401,
|
||||||
response.data[2]["WWW-Authenticate"] = "Bearer"
|
headers & @{"Content-Type": TXT},
|
||||||
response.data[2]["Content-Type"] = TXT
|
getCurrentExceptionMsg())
|
||||||
response.data[3] = getCurrentExceptionMsg()
|
|
||||||
|
|
||||||
proc start*(cfg: PitApiCfg) =
|
proc start*(cfg: PitApiCfg) =
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
const PIT_VERSION = "4.4.2"
|
const PIT_VERSION* = "4.4.3"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user