Skip to content

Instantly share code, notes, and snippets.

Last active Dec 14, 2015
What would you like to do?
(ns helloworld.handler
(:require [compojure.core :refer :all]
[compojure.handler :as handler]
[compojure.route :as route]
[korma.db :refer [defdb sqlite3]]
[korma.core :as korma]
[hiccup.core :refer [html]]))
(defdb db (sqlite3
{:db "db/helloworld.sqlite3"}))
(korma/defentity items)
(def all-items (korma/select items))
(defn to-html [items]
[:head [:title "Access DB using Korma."]]
(map (fn [i] [:li (:title i)]) items)]]))
(defroutes app-routes
(GET "/" [] (to-html all-items))
(route/not-found "Not Found"))
(def app
(handler/site app-routes))
(defproject helloworld "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url ""
:dependencies [[org.clojure/clojure "1.4.0"]
[compojure "1.1.5"]
[org.xerial/sqlite-jdbc "3.7.2"]
[korma "0.3.0-RC2"]
[hiccup "1.0.2"]]
:plugins [[lein-ring "0.8.2"]]
:ring {:handler helloworld.handler/app}
{:dev {:dependencies [[ring-mock "0.1.3"]]}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment