From 6f203c26ea986f74ffbd8dcfb50ff2f556419378 Mon Sep 17 00:00:00 2001 From: gered Date: Thu, 8 Jan 2015 18:31:14 -0500 Subject: [PATCH] add common http response helper functions --- src/clj_webtoolbox/response_helpers.clj | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/clj_webtoolbox/response_helpers.clj diff --git a/src/clj_webtoolbox/response_helpers.clj b/src/clj_webtoolbox/response_helpers.clj new file mode 100644 index 0000000..1d66849 --- /dev/null +++ b/src/clj_webtoolbox/response_helpers.clj @@ -0,0 +1,22 @@ +(ns clj-webtoolbox.response-helpers + (:require + [clj-webtoolbox.response :as response])) + +(defn- ->response [body status] + (-> (response/content body) + (response/status status))) + +(defn ok [body] (->response body 200)) +(defn created [body] (->response body 201)) +(defn accepted [body] (->response body 202)) +(defn no-content [body] (->response body 204)) + +(defn moved [body] (->response body 301)) +(defn found [body] (->response body 302)) + +(defn bad-request [body] (->response body 400)) +(defn unauthorized [body] (->response body 401)) +(defn forbidden [body] (->response body 403)) +(defn not-found [body] (->response body 404)) + +(defn error [body] (->response body 500))