 				[ring.middleware.params]
 				[ring.middleware.multipart-params]
 				[ring.middleware.stacktrace]
+				[clojure.stacktrace] ; XXX
 				[sandbar stateful-session auth validation])
 	(:require	[compojure.route :as route]
 				[compojure.handler :as handler]

	

	; "post urls"
	(GET "/blog/:bid/post/" [bid :as request]
		(render-html-posts
				(data/get-posts (Integer/parseInt bid) 10 0)
				(util/uri-from-request request)
				(:title (data/get-blog (Integer/parseInt bid)))
				bid))
	(GET "/blog/:bid/post/new" [bid]
		(if (not (data/blog-owner? bid))
			(redirect templates/*permission-denied-uri*)

		(wrap-params)
		(wrap-json-params)))

(defn start-server [join]
	(let [port (System/getenv "PORT")
			port (if (nil? port) "3000" port)
			port (Integer/parseInt port)
			ssl-port templates/*https-port*]
		(jetty/run-jetty (app port ssl-port)
				{:join? join :port port :ssl-port ssl-port
						:keystore "devonly.keystore" :key-password "foobar"})))

(defn -main []
	(start-server true))
