title: Using LevelDB in a ring/compojure webapp
body: <p>I am am trying to setup LevelDB in a ring/compojure app, and looking for an idiomatic way to to access the opened db descriptor into each request.</p>
  
  <p>For example:</p>
  
  <pre><code>(defn -main
    "I don't do a whole lot ... yet."
    [&amp; args]
  
    (println "Opening LevelDB file in db/main")
    (with-open [main-db (db/open "db/main")]
  
      (println "Running server on port 3000")
      (run-jetty #'web/app {:port 3000})))
  </code></pre>
  
  <p>How do you access the <code>main-db</code> descriptor into the request handlers?</p>
  
  <p>ie.:</p>
  
  <pre><code>(defroutes handler
  
    (GET "/test" []
      (db/put main-db (.getBytes "testKey2") (.getBytes "testValue2"))
      "&lt;h1&gt;Hello World&lt;/h1&gt;")
  </code></pre>
  
  <p>PS: I am using the leveldb-clj lib from Sedward and packaged it into a clojar: <a href="https://clojars.org/org.clojars.aircart/leveldb-clj" rel="nofollow">https://clojars.org/org.clojars.aircart/leveldb-clj</a></p>