Skip to content

Instantly share code, notes, and snippets.

Created Aug 17, 2014
What would you like to do?
(ns example-component-ring.handler
(:require [clojure.string :as str]
[compojure.core :refer :all]
[compojure.handler :as handler]
[compojure.route :as route]
[monger.collection :as mc]
[monger.core :as mg]))
(defn get-entries [{:keys [connection]}]
(let [db (mg/get-db connection "mydb")]
(mc/find db "entries" {})))
(defn get-entry-list [db]
(let [entries (get-entries db)]
(str/join "<br />" (map #(get % "title") entries))))
(defroutes app-routes
(GET "/" [:as {db :db}] (get-entry-list db))
(route/resources "/")
(route/not-found "Not Found"))
(def app
(handler/site app-routes))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment