When requested ChoD is lower than permitted, use minimal no default as per #2
This commit is contained in:
parent
25da07882c
commit
7d1e5d9996
1 changed files with 13 additions and 9 deletions
|
@ -100,17 +100,21 @@
|
|||
rss-thread-watch.watcher.chod-threads-cache
|
||||
rss-thread-watch.core.CONFIG"
|
||||
[rqst]
|
||||
(try (let [{{chod "chod" :or {chod 60}
|
||||
(try (let [{{chod "chod" :or {chod "94"}
|
||||
:as prms} :params
|
||||
uri :uri} rqst
|
||||
queries (if (vector? (prms "q")) (prms "q") [(prms "q")]) ; to always return vector
|
||||
qrs (prms "q")
|
||||
queries (if (vector? qrs) qrs [qrs]) ; to always return vector
|
||||
repeat? (prms "repeat")
|
||||
real-chod (try ;If we can't parse number from give chod param, just use 94
|
||||
(if (or (vector? chod)
|
||||
(< (Integer/parseInt chod) 60)) ; Never accept chod lower that 60 TODO: don't hardcode this
|
||||
94 (Integer/parseInt chod))
|
||||
(catch Exception e
|
||||
94))
|
||||
real-chod (if-let [ch (or (and (vector? chod)
|
||||
(first chod))
|
||||
chod)]
|
||||
(try ;If we can't parse number from chod, use default 94
|
||||
(if (or (vector? chod)
|
||||
(<= (Integer/parseInt chod) 60)) ; Never accept chod lower that 60 TODO: don't hardcode this
|
||||
60 (Integer/parseInt chod))
|
||||
(catch Exception e
|
||||
94)))
|
||||
cache @watcher/chod-threads-cache]
|
||||
;; (println "RCVD: " rqst)
|
||||
(println rqst)
|
||||
|
@ -146,7 +150,7 @@
|
|||
:body (generate-feed queries real-chod repeat? cache)})
|
||||
(catch Exception e
|
||||
;; Ex-info has been crafted to match HTTP response body so we can send it
|
||||
(if-let [caught (ex-data e)] ;Tam bude ale vždycky ex-data myslím, to chce čekovat jestli t obsahuje nějaký klíč (body? at nemusí být nějaký extra)
|
||||
(if-let [caught (ex-data e)]
|
||||
caught ;We have custom crafted error
|
||||
{:status 500 ;Something else fucked up, we print what happened
|
||||
:header {"Content-Type" "text/plain"}
|
||||
|
|
Loading…
Reference in a new issue