HttpAuthHook use async raises

This commit is contained in:
jangko 2024-01-27 18:00:02 +07:00
parent addfc322f5
commit c5c40af304
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
2 changed files with 3 additions and 2 deletions

View File

@ -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

View File

@ -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)