Closed reesmichael1 closed 2 years ago
I have the same issue with my nimnews package. The code is rather simple:
proc root*(req: Request): Future[ResponseData] {.async.} =
block route:
redirect("/group/")
I am having similar issues with Jester 0.5.0
. When I use the macro routes:
if I add the error
block I can't use redirect
routes:
get "/":
redirect "/blog"
error {Http401 .. Http408}:
redirect "/somepathhere"
The redirect in the get:
block will work just fine, but the redirect in the error:
block will throw
Error: undeclared identifier: 'allRoutes'
Then if I move to a custom match proc like in exmaple2 I can't use redirect
at all
proc match(request: Request): Future[ResponseData] {.async.} =
block route:
case request.pathInfo
of "/":
redirect "/blog"
else:
resp Http404, "Not found!"
The redirect
in the of "/"
will throw Error: undeclared identifier: 'allRoutes'
I am using: nim v1.4.8 Windows WSL Ubuntu 20.04
First, thanks for all your work on Jester! It's a very nice framework.
It seems that it's no longer possible to use a redirect within an error block with
0.5.0
. With Jester0.4.3
, this snippet compiles and works as expected:With
0.5.0
, I get the following compilation error:If I change the
redirect
to aresp
, the sample successfully compiles.I haven't dug into it enough to be certain, but it seems likely that this is due to the changes in #265. Adding
halt = false
to the redirect call makes no difference.