more specs.

This commit is contained in:
Bryce Covert
2018-04-09 16:27:03 -07:00
parent f7dea19d2e
commit 5e7add409f
25 changed files with 246 additions and 209 deletions

View File

@@ -1,5 +1,6 @@
(ns auto-ap.routes.utils
(:require [buddy.auth :refer [authenticated?]]))
(:require [clojure.spec.alpha :as s]
[buddy.auth :refer [authenticated?]]))
(defn wrap-secure [handler]
(fn [request]
@@ -7,3 +8,11 @@
(handler request)
{:status 401
:body "not authenticated"})))
(defn wrap-spec [handler spec]
(fn [request]
(if (not (s/valid? spec (:edn-params request)))
{:status 400
:body (pr-str (s/explain-data spec (:edn-params request)))
:headers {"Content-Type" "application/edn"}}
(handler request))))