Skip to content

Instantly share code, notes, and snippets.

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