Learning Clojure — day 7

Compojure: routing for your application

(defroutes app-routes
(GET "/" [] "Hello World")
(POST "/login" [email password]
(handle-login email password)))
lein new compojure hello-world

Ring: http server abstraction

lein ring server
(response "Hello World")

=> {:status 200
:headers {}
:body "Hello World"}

Hiccup: rendering HTML

(html [:div {:class "foo"} "bar"]) 
=> "<div class=\"foo\">bar</div>"
(defn users []

(defn user-row [user]
[:li (:name user)])

(defn users-page []
(map user-row users)]))

Feels good

Dmitriy Zaporozhets

Written by

Ruby developer, GitLab cofounder

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade