diff options
| author | eltrac <hi@eltr.ac> | 2026-05-09 15:02:06 +0800 |
|---|---|---|
| committer | eltrac <hi@eltr.ac> | 2026-05-09 15:02:06 +0800 |
| commit | a21df20fc84b2c13af6a88974f3f4d6763fc5766 (patch) | |
| tree | f2920ac32fd9aced281c5a889dcf4c2398448d1c /src | |
| parent | 6fd4ca2ea51b9e9beba0c74eff6c48a9b61c6ac2 (diff) | |
refactor: improve retriever/respond-webmention-json DRYness
Diffstat (limited to 'src')
| -rw-r--r-- | src/weepinbell/retriever.clj | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/weepinbell/retriever.clj b/src/weepinbell/retriever.clj index 1da6422..d13a702 100644 --- a/src/weepinbell/retriever.clj +++ b/src/weepinbell/retriever.clj @@ -7,15 +7,13 @@ ;; utilities (defn- respond-webmention-json [data] - (if data - {:status 200 - :headers {"Content-Type" "application/json; charset=utf-8"} - :body data} - ;; if no data found, respond 404 - {:status 404 - :headers {"Content-Type" "application/json; charset=utf-8"} - :body {:status 404 - :message "Webmention does not exist or is pending for verification."}})) + (let [base-resp {:status 200 + :headers {"Content-Type" "application/json; charset=utf-8"} + :body nil}] + (if data + (assoc base-resp :body data) + (assoc (assoc base-resp :status 400) + :body "The requested webmention does not exist.")))) (defn- partition-pages [page size data] @@ -33,7 +31,7 @@ (defn- respond-webmention-list-json [data] (let [base-resp {:status 200 :headers {"Content-Type" "application/json; charset=utf-8"} - :body []}] + :body nil}] (if data (assoc base-resp :body data) (assoc (assoc base-resp :status 400) |
