summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/weepinbell/webserver/receiver.clj13
-rw-r--r--test/weepinbell/receiver_test.clj2
2 files changed, 5 insertions, 10 deletions
diff --git a/src/weepinbell/webserver/receiver.clj b/src/weepinbell/webserver/receiver.clj
index 1a34f8c..ab55ccf 100644
--- a/src/weepinbell/webserver/receiver.clj
+++ b/src/weepinbell/webserver/receiver.clj
@@ -1,6 +1,7 @@
(ns weepinbell.webserver.receiver
"Service receiving Webmention request (a source and a target); verify the request; return error message if any; push Webmention into webbmention channel for processor to take."
(:require [clojure.core.async :refer [put!]]
+ [ring.util.http-response :refer [bad-request created]]
[weepinbell.utils.url :refer [get-domain valid-http-url? normalize url=]]
[weepinbell.utils.digest :refer [digest]]))
@@ -45,10 +46,8 @@
;; Request verification
(if-let [error-msg (check-request source target allowlist)]
;; respond if request verification failed
- {:status 400
- :headers {"Content-Type" "application/json; charset=utf-8"}
- :body {:status 400
- :message error-msg}}
+ (bad-request {:status 400
+ :message error-msg})
;; proceed if request is ok
(do
;; The receiver SHOULD check that target is a valid
@@ -66,9 +65,5 @@
response {:status 201
:message "Webmention is accepted and pending for verification."
:url wm-url}]
- {:status 201
- :headers {"Location" wm-url
- "Content-Type" "application/json; charset=utf-8"}
- :body response})))))
-
+ (created wm-url response))))))
diff --git a/test/weepinbell/receiver_test.clj b/test/weepinbell/receiver_test.clj
index 06c2ce9..d834f56 100644
--- a/test/weepinbell/receiver_test.clj
+++ b/test/weepinbell/receiver_test.clj
@@ -22,7 +22,7 @@
:identical "Source and target are identical."
:domain-not-allowed "Domain of target is not allowed. This receiver does not receive webmention on its behalf."})]
{:status 400
- :headers {"Content-Type" "application/json; charset=utf-8"}
+ :headers {}
:body {:status 400
:message msg}}))
;; end utilities