From c5c40af3043d72abdd92b3e846f2e747bd535704 Mon Sep 17 00:00:00 2001 From: jangko Date: Sat, 27 Jan 2024 18:00:02 +0700 Subject: [PATCH] HttpAuthHook use async raises --- json_rpc/servers/httpserver.nim | 2 +- tests/testhook.nim | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/json_rpc/servers/httpserver.nim b/json_rpc/servers/httpserver.nim index c122ad8..47b88b0 100644 --- a/json_rpc/servers/httpserver.nim +++ b/json_rpc/servers/httpserver.nim @@ -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 diff --git a/tests/testhook.nim b/tests/testhook.nim index 99b2337..1fbb020 100644 --- a/tests/testhook.nim +++ b/tests/testhook.nim @@ -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)