Show error page when rate limited

This commit is contained in:
Zed
2021-01-07 22:31:29 +01:00
parent 2128b280b4
commit 4e1d213488
6 changed files with 25 additions and 5 deletions

View File

@ -1,5 +1,6 @@
import asyncdispatch, strformat
from net import Port
from htmlgen import a
import jester
@ -9,6 +10,8 @@ import routes/[
preferences, timeline, status, media, search, rss, list,
unsupported, embed, resolver, router_utils]
const instancesUrl = "https://github.com/zedeus/nitter/wiki/Instances"
const configPath {.strdefine.} = "./nitter.conf"
let (cfg, fullCfg) = getConfig(configPath)
@ -71,6 +74,12 @@ routes:
error Http404:
resp Http404, showError("Page not found", cfg)
error RateLimitError:
echo error.exc.msg
resp Http429, showError("Instance has been rate limited.<br>Use " &
a("another instance", href = instancesUrl) &
" or try again later.", cfg)
extend unsupported, ""
extend preferences, ""
extend resolver, ""