Last active
August 29, 2015 14:11
-
-
Save laser/06c7d022f6ceb3b4bc87 to your computer and use it in GitHub Desktop.
Validation-in-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 bad-request | |
"Generate an HTTP response map representing a Bad Request." | |
[body] | |
(assoc (response body) :status 400)) | |
(defn ok | |
"Generate an HTTP response map representing a successful request." | |
[body] | |
(assoc (response body) :status 200)) | |
(defn post-notes-handler | |
[req-body] | |
(let [[note error] (validate-note req-body)] | |
(if error | |
(bad-request error) | |
(ok note)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment