Skip to content

Instantly share code, notes, and snippets.

@hendore
Created October 9, 2019 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hendore/2d8686fddcec2342688372b300d811e6 to your computer and use it in GitHub Desktop.
Save hendore/2d8686fddcec2342688372b300d811e6 to your computer and use it in GitHub Desktop.
Clojure account registration
(declare insert-account! send-welcome-email!)
(defn register-account!
[account-info]
(when-let [account (insert-account! account-info)]
(send-welcome-email! account)))
(defn- insert-account!
[account-info]
(let [account (select-keys account-info [:name :email :phone :password])]
(jdbc/insert! pgsql-config :accounts account {:result-set-fn first})))
(defn- send-welcome-email!
[{:keys [email]}]
(str "Sending welcome email to " email))
(defn registration-req-handler
[request]
(register-account! (request :body)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment