Created
January 6, 2011 22:52
-
-
Save mirrormatch/768768 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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