Created
January 9, 2021 23:18
-
-
Save cindywu/d5b3b714d3a9913a4f71162abfb893b7 to your computer and use it in GitHub Desktop.
guestbook-cljs/src/clj/guestbook/routes/home.clj
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 save-message! [{:keys [params]}] | |
(if-let [errors (validate-message params)] | |
(response/bad-request {:errors errors}) | |
(try | |
(db/save-message! | |
(assoc params :timestamp (java.util.Date.))) | |
(response/ok {:status :ok}) | |
(catch Exception e | |
(response/internal-server-error | |
{:errors {:server-error ["Failed to save message!"]}}))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment