Created
January 19, 2010 15:47
-
-
Save jcromartie/281015 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn with-json [handler] | |
(fn [request] | |
(json/encode-to-str (handler request)))) | |
(defn with-requires-https [handler] | |
(fn [request] | |
(if (= :https (:scheme request)) | |
(handler request) | |
"No way José"))) | |
(defn with-requires-authentication [handler] | |
(fn [request] | |
(let [id (-> request :route-params :id) | |
pw (-> request :params :password)] | |
(if (access/authenticate id pw) | |
(handler request) | |
"No way José")))) | |
(defroutes signup-api | |
; create an account | |
(POST "/accounts/" (decorate account-create (with-json))) | |
; get account info | |
(GET "/accounts/:id/" (decorate account-info (with-json))) | |
; update account info | |
(POST "/accounts/:id/" (decorate account-update | |
(with-requires-authentication) | |
(with-json))) | |
(ANY "/*" four-oh-four)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment