<commit_before>(ns demo.web
  (:use [clojure.pprint :only [pprint]])
  (:require [immutant.web             :as web]
            [immutant.web.session     :as immutant-session]
            [immutant.util            :as util]
            [ring.middleware.session  :as ring-session]
            [ring.middleware.resource :as ring-resource]
            [ring.util.response       :as ring-util]))

(defn request-dumper
  "A very simple ring handler"
  [request]
  {:status 200
   :headers {"Content-Type" "text/plain"}
   :body (with-out-str (pprint request))})
;;; Mount the handler relative to the app's context path [/demo]
(web/start request-dumper)


(defn world-greeter
  "An even simpler ring handler"
  [request]
  {:status 200
   :headers {"Content-Type" "text/html"}
   :body "<h1>Hello World</h1>"})
;;; Mount it at a "sub context path" [/demo/hello]
(web/start "/hello" world-greeter)


;;; Lifted from https://github.com/ring-clojure/ring/wiki/Sessions
(defn counter [{session :session}]
  (let [count (:count session 0)
        session (assoc session :count (inc count))]
    (-> (ring-util/response (str "You accessed this page " count " times."))
        (assoc :session session))))
;;; Use Immutant's session store for automatic replication
(web/start "/counter"
 (ring-session/wrap-session
  #'counter
  {:store (immutant-session/servlet-store)}))


;;; Static resource middleware
;;; See https://github.com/ring-clojure/ring/wiki/Static-Resources
(web/start (ring-resource/wrap-resource #'request-dumper "public"))


;;; Handy utilities
(util/in-immutant?)
(util/app-relative "src")
(util/http-port)
(util/context-path)
(util/app-uri)
<commit_msg>Minor<commit_after>(ns demo.web
  (:use [clojure.pprint :only [pprint]])
  (:require [immutant.web             :as web]
            [immutant.web.session     :as immutant-session]
            [immutant.util            :as util]
            [ring.middleware.session  :as ring-session]
            [ring.middleware.resource :as ring-resource]
            [ring.util.response       :as ring-util]))

(defn request-dumper
  "A very simple ring handler"
  [request]
  {:status 200
   :headers {"Content-Type" "text/plain"}
   :body (with-out-str (pprint request))})
;;; Mount the handler relative to the app's context path [/demo]
(web/start request-dumper)


(defn world-greeter
  "An even simpler ring handler"
  [request]
  {:status 200
   :headers {"Content-Type" "text/html"}
   :body "<h1>Hello World</h1>"})
;;; Mount it at a "sub context path" [/demo/hello]
(web/start "/hello" world-greeter)


;;; Lifted from https://github.com/ring-clojure/ring/wiki/Sessions
(defn counter [{session :session}]
  (let [count (:count session 0)
        session (assoc session :count (inc count))]
    (-> (ring-util/response (str "You accessed this page " count " times\n"))
        (assoc :session session))))
;;; Use Immutant's session store for automatic replication
(web/start "/counter"
 (ring-session/wrap-session
  #'counter
  {:store (immutant-session/servlet-store)}))


;;; Static resource middleware
;;; See https://github.com/ring-clojure/ring/wiki/Static-Resources
(web/start (ring-resource/wrap-resource #'request-dumper "public"))


;;; Handy utilities
(util/in-immutant?)
(util/app-relative "src")
(util/http-port)
(util/context-path)
(util/app-uri)

{'fraction_non_alphanumeric': 0.15625942684766214, 'fraction_numerical': 0.005429864253393665, 'mean_word_length': 3.3009079118028533, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5676442', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1102, 'n_words': 280}