Skip to content

Instantly share code, notes, and snippets.

@dsp
Created February 27, 2010 10:28
Show Gist options
  • Save dsp/316623 to your computer and use it in GitHub Desktop.
Save dsp/316623 to your computer and use it in GitHub Desktop.
(ns net.experimentalworks.clojure.comp
(:use compojure))
(defroutes helloworld-routes
(GET "/login/:user"
[(session-assoc :loggedin (:user params))
(html [:html [:body [:p "You are now logged in as " (:user params)]]])])
(GET "/logout"
(if (contains? session :loggedin)
[(session-dissoc :loggedin)
(html [:html [:body [:p "Logged out"]]])]
(html [:html [:body [:p "You are not logged in"]]])))
(GET "/*"
(if (contains? session :loggedin)
(html [:html [:body [:p "Welcome back " [:b (:loggedin session)]]]])
(html [:html [:body [:p "Hello World"]]]))))
(decorate helloworld-routes (with-session :memory))
(run-server {:port 8080}
"/*" (servlet helloworld-routes))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment