Skip to content

Instantly share code, notes, and snippets.

@EmmanuelOga
Created May 24, 2020 06:52
Show Gist options
  • Save EmmanuelOga/8b502f590bdedd5890bd65921f35b9f9 to your computer and use it in GitHub Desktop.
Save EmmanuelOga/8b502f590bdedd5890bd65921f35b9f9 to your computer and use it in GitHub Desktop.
minimal ring session example
(ns anillo.core
(:require [ring.adapter.jetty :refer :all]
[ring.middleware.session :refer :all]
[ring.util.response :refer :all]))
(defn handler [{session :session}]
(let [n (session :n 1)]
(-> (response (str "You have visited " n " times"))
(assoc-in [:session :n] (inc n)))))
(def app
(-> handler wrap-session))
(defn run
[]
(run-jetty app {:port 3000}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment