Do not set default instance

This commit is contained in:
arne 2023-10-06 19:30:13 +02:00
commit 51b7139e80

View file

@ -78,16 +78,18 @@
[::xspf/location (:url file)]])) statuses)]])) [::xspf/location (:url file)]])) statuses)]]))
(defn app [req] (defn app [req]
(let [instance-url (if (not= "/" (:uri req)) (if (= "/" (:uri req))
(str "https://" {:status 400
:headers {"Content-Type" "text/plain"}
:body "Please use the path to set an instance URL, for example /merveilles.town.xspf."}
(let [instance-url (str "https://"
(-> (str/replace (:uri req) #"^/" "") (-> (str/replace (:uri req) #"^/" "")
(str/replace #".xspf$" ""))) (str/replace #".xspf$" "")))
"https://post.lurk.org") token (some-> (:body req) (slurp) (json/parse-string true) :token)
token (some-> (:body req) (slurp) (json/parse-string true) :token) statuses (fetch-loops instance-url token)]
statuses (fetch-loops instance-url token)] {:status 200
{:status 200 :headers {"Content-Type" "application/xspf+xml"}
:headers {"Content-Type" "application/xspf+xml"} :body (xml/indent-str (->xspf statuses))})))
:body (xml/indent-str (->xspf statuses))}))
(defonce server (defonce server
(atom nil)) (atom nil))