Created
October 6, 2010 11:06
-
-
Save svs/613185 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
;; 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