ClojureでのWEBアプリ開発にあたって、各種ライブラリのメモ
ClojureでWEBアプリ開発してみようと思う。
まずは、利用予定のライブラリについて簡単にメモ。
利用ライブラリ
Compojure(& Ring)のHello World
プロジェクト作成
lein new compojure hello-world
Ring起動(Jettyが立ち上がる)
cd hello-world lein ring server 3000
war作成(2013/06/29追記)
lein ring uberwar
HiccupのHello World
実行
lein repl
(use 'hiccup.core)
(html [:div#foo.bar.baz "bang"])
(html [:span {:class "foo"} "bar"])
(html [:ul
(for [x (range 1 4)]
[:li x])])
KormaのHello World
導入
project.clj の dependency に以下を追記。
[korma "0.3.0-RC5"]
また、利用したいDBMS製品用のJDBCドライバも追記しておく。(下記はSQLiteの例)
[org.xerial/sqlite-jdbc "3.7.2"]
実行
(use 'korma.db)
(defdb db (sqlite3 {:db "SQLiteのデータベースファイルのパス。例)C:/db/test.db"}))
(use 'korma.core)
(defentity account)
(select account)
(select account
(fields :day :comment)
(where {
:year "2011"
:month "6"}))