Skip to content

Instantly share code, notes, and snippets.

@mirrormatch
Created January 6, 2011 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirrormatch/768768 to your computer and use it in GitHub Desktop.
Save mirrormatch/768768 to your computer and use it in GitHub Desktop.
(ns comp2.core
(:use compojure.core)
(:require [compojure.route :as route]
[ring.middleware.session :as session]
[ring.adapter.jetty :as jetty]))
(defn set-session-var [session]
(if (:my-var session)
{:body "Session variable already set"}
{:body "Nothing in session, setting the var"
:session (assoc session :my-var "foo")}))
(defroutes sessiontest-routes
(ANY "/" {session :session} (set-session-var session))
(route/not-found "Page not found"))
(def sessiontest-app
(-> sessiontest-routes
session/wrap-session))
(defn start-server []
(future (jetty/run-jetty (var sessiontest-app) {:port 8081})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment