Book Image

Clojure Web Development Essentials

By : Ryan Baldwin
Book Image

Clojure Web Development Essentials

By: Ryan Baldwin

Overview of this book

Table of Contents (19 chapters)
Clojure Web Development Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adjusting the database connection


In essence, the Configuration principle of the 12 Factor-Application Pattern states that an application's configuration and an application's code should be completely independent of each other. Our hipstr application currently violates this principle in a key area: the database connection. This, however, is easily resolved.

Creating the profiles.clj file

For our development server, we will create profiles.clj and have the lein-env plugin generate the .lein-env file. Currently, our hipstr.models.connection/db-spec expects 5 settings: :classname, :subprotocol, :subname, :user, and :password.

Theoretically, we could transfer the entire db-spec map into the profiles.clj file, such as shown below:

{:dev {:env {:db-spec {:classname   "org.postgresql.Driver"
                       :subprotocol "postgresql"
                       :subname     "//localhost/postgres"
                       :user        "hipstr"
                       :password    "p455w0rd})

We could then...