Skip to content

Instantly share code, notes, and snippets.

@laser
Last active August 29, 2015 14:11
Show Gist options
  • Save laser/06c7d022f6ceb3b4bc87 to your computer and use it in GitHub Desktop.
Save laser/06c7d022f6ceb3b4bc87 to your computer and use it in GitHub Desktop.
Validation-in-pipeline
(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