Skip to content

Instantly share code, notes, and snippets.

@svs
Created October 6, 2010 11:06
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 svs/613185 to your computer and use it in GitHub Desktop.
Save svs/613185 to your computer and use it in GitHub Desktop.
;; example rails like console for compojure showing params, etc. for each request
(ns bus.core
(:use compojure.core
ring.adapter.jetty
...
...
(:use ring.middleware.params))
(defroutes example
(GET "/" [] "hello world"))
;; a small middleware that writes to a file called "log.txt". run tail -f on this file to get the console.
(defn wrap-debug [app]
(fn [request]
(do
(clojure.contrib.duck-streams/append-spit "log.txt"
(str (dissoc request :headers) "\n-----------------\n"))
(app request))))
(def bus-app
(-> (var example)
(wrap-debug)
(wrap-reload '(bus.core))
(wrap-stacktrace)
(wrap-params)
))
(defn dev []
(run-jetty #'bus-app {:port 8080}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment