Skip to content

Commit

Permalink
back to raising hooks
Browse files Browse the repository at this point in the history
Makes update less intrusive, even if it doesn't make a practical
difference
  • Loading branch information
arnetheduck committed Oct 20, 2024
1 parent 12f6cb8 commit 038a94b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion json_rpc/servers/httpserver.nim
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ type
# - nil: auth success, continue execution
# - HttpResponse: could not authenticate, stop execution
# and return the response
HttpAuthHook* = proc(request: HttpRequestRef): Future[HttpResponseRef] {.async.}
HttpAuthHook* =
proc(request: HttpRequestRef): Future[HttpResponseRef] {.async: (raises: [CatchableError]).}

# This inheritance arrangement is useful for
# e.g. combo HTTP server
Expand Down
3 changes: 2 additions & 1 deletion json_rpc/servers/websocketserver.nim
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ type
# - true: auth success, continue execution
# - false: could not authenticate, stop execution
# and return the response
WsAuthHook* = proc(request: HttpRequest): Future[bool] {.async.}
WsAuthHook* =
proc(request: HttpRequest): Future[bool] {.async: (raises: [CatchableError]).}

# This inheritance arrangement is useful for
# e.g. combo HTTP server
Expand Down
2 changes: 1 addition & 1 deletion tests/testhook.nim
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ proc authHeaders(): seq[(string, string)] =
@[("Auth-Token", "Good Token")]

suite "HTTP server hook test":
proc mockAuth(req: HttpRequestRef): Future[HttpResponseRef] {.async.} =
proc mockAuth(req: HttpRequestRef): Future[HttpResponseRef] {.async: (raises: [CatchableError]).} =
if req.headers.getString("Auth-Token") == "Good Token":
return HttpResponseRef(nil)

Expand Down

0 comments on commit 038a94b

Please sign in to comment.