Last active
October 2, 2019 14:48
-
-
Save rlander/a0375b06f2b92b3298c67c43352776a5 to your computer and use it in GitHub Desktop.
This file contains 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
(ns myapi.interceptors) | |
(def user-auth | |
{:before (fn [context] | |
(update-in context :password h/encrypt-password)) | |
:after (fn [context] | |
(dissoc context [:password]))}) | |
(def interceptors [user-auth]) |
This file contains 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
(ns myapi.routes) | |
(def routes | |
(start-server ... | |
(mount ::myapi.my-service ::myapi.interceptors))) |
This file contains 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
(ns myapi.services) | |
(defn fetch [id params] | |
(db/select-one id params)) | |
(defn fetch* [params] | |
(db/select params)) | |
(defn create! [data params] | |
(db/insert! data params)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using services with full interceptors: