Skip to content

Commit

Permalink
HttpAuthHook use async raises
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko committed Jan 27, 2024
1 parent addfc32 commit c5c40af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion json_rpc/servers/httpserver.nim
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type
# - HttpResponse: could not authenticate, stop execution
# and return the response
HttpAuthHook* = proc(request: HttpRequestRef): Future[HttpResponseRef]
{.gcsafe, raises: [Defect, CatchableError].}
{.gcsafe, async: (raises: [CatchableError]).}

# This inheritance arrangement is useful for
# e.g. combo HTTP server
Expand Down
3 changes: 2 additions & 1 deletion tests/testhook.nim
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ 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] {.
gcsafe, async: (raises: [CatchableError]).} =
if req.headers.getString("Auth-Token") == "Good Token":
return HttpResponseRef(nil)

Expand Down

0 comments on commit c5c40af

Please sign in to comment.