Last active
August 29, 2015 14:11
-
-
Save laser/7aacff2773abbaeb00af to your computer and use it in GitHub Desktop.
Adding database to pipeline
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 internal-error | |
"Generate an HTTP response map representing an Internal Server Error." | |
[body] | |
(assoc (response body) :status 500)) | |
(defn post-notes-handler | |
"Map an HTTP request to a newly-created note." | |
[req-body] | |
(let [[note error] (validate-note req-body)] | |
(if error | |
(bad-request error) | |
(let [[id error] (create-note req-body)] | |
(if error | |
(internal-error error) | |
(ok (assoc req-body :id id))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment