-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix error handler redirecting (#275)
* Fixes crash described in #296. * Fix #211 - custom routers now get the same default error handling as normal routers * Add changelog entry * Fix #269 - you can now redirect within error handlers again * Preserve backward compatibility in `initJester` * Restore `initJester` proc for MatchProcSync matchers Co-authored-by: Dominik Picheta <[email protected]>
- Loading branch information
Showing
4 changed files
with
112 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import jester | ||
|
||
router myrouter: | ||
get "/": | ||
resp "Hello world" | ||
|
||
get "/404": | ||
resp "you got 404" | ||
|
||
get "/raise": | ||
raise newException(Exception, "Foobar") | ||
|
||
error Exception: | ||
resp Http500, "Something bad happened: " & exception.msg | ||
|
||
error Http404: | ||
redirect uri("/404") | ||
|
||
when isMainModule: | ||
let s = newSettings( | ||
Port(5454), | ||
bindAddr="127.0.0.1", | ||
) | ||
var jest = initJester(myrouter, s) | ||
jest.serve() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters