diff options
Diffstat (limited to 'src/chef/utils.clj')
-rw-r--r-- | src/chef/utils.clj | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/chef/utils.clj b/src/chef/utils.clj new file mode 100644 index 0000000..a721617 --- /dev/null +++ b/src/chef/utils.clj @@ -0,0 +1,15 @@ +(ns chef.utils + (:require [ring.util.response :as ruresp])) + +(defn gen-page [title & content] + [:html + [:head + [:meta {:name "viewport" :content "width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"}] + [:title title]] + (apply conj [:body] content [[:script {:src "/static/htmx.js"}]])]) + +(defmacro auth-only [request & body] + `(if (some? (get-in ~request [:session :oauth-token])) + (do ~@body) + ~(-> (ruresp/response "Unauthorized.") + (ruresp/status 401)))) |