-
-
Save mefesto/6b981042c27cacfd975a to your computer and use it in GitHub Desktop.
This file contains 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 wrap-db-connection [handler config] | |
(let [ds (doto (BasicDataSource.) | |
(.setDriverClassName (:driver-classname config)) | |
(.setUrl (:url config)) | |
(.setUsername (:username config)) | |
(.setPassword (:password config)))] | |
(fn [request] | |
(sql/with-connection {:datasource ds} | |
(handler request))))) | |
;; in some main file | |
(defn -main [& args] | |
(let [config (read-config (first args))] | |
(run-jetty | |
(-> web/handler | |
wrap-params | |
(wrap-db-connection config)) | |
{:port (:port config)}))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment