From 51b7139e8043f702529a955d64c7c0e3bf27d6a2 Mon Sep 17 00:00:00 2001 From: arne Date: Fri, 6 Oct 2023 19:30:13 +0200 Subject: [PATCH] Do not set default instance --- looptober.clj | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/looptober.clj b/looptober.clj index a9fa26a..60e9dac 100644 --- a/looptober.clj +++ b/looptober.clj @@ -78,16 +78,18 @@ [::xspf/location (:url file)]])) statuses)]])) (defn app [req] - (let [instance-url (if (not= "/" (:uri req)) - (str "https://" + (if (= "/" (:uri req)) + {: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 #".xspf$" ""))) - "https://post.lurk.org") - token (some-> (:body req) (slurp) (json/parse-string true) :token) - statuses (fetch-loops instance-url token)] - {:status 200 - :headers {"Content-Type" "application/xspf+xml"} - :body (xml/indent-str (->xspf statuses))})) + token (some-> (:body req) (slurp) (json/parse-string true) :token) + statuses (fetch-loops instance-url token)] + {:status 200 + :headers {"Content-Type" "application/xspf+xml"} + :body (xml/indent-str (->xspf statuses))}))) (defonce server (atom nil))