 		(wrap-params)
 		(wrap-json-params)))
 
-(defn -main []
+(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)
-				{:port port :ssl-port ssl-port
+				{:join? join :port port :ssl-port ssl-port
 						:keystore "devonly.keystore" :key-password "foobar"})))
+
+(defn -main []
+	(start-server true))

	

	; "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*)

(defn ensure-secure [request]
	(= :https (:scheme request)))

(defn render-html-posts-helper [blogid request]
	(render-html-posts
		(data/get-posts blogid 10 0)
		(util/uri-from-request request)
		(:title (data/get-blog blogid))
		blogid))


(defroutes main-routes
	(GET "/" [:as request]
		(let [server-name (str
						(:server-name request)
						(if (not (nil? (:server-port request)))
							(str ":" (:server-port request))))
				uri (:uri request)]
			(let [domain (data/get-domain server-name)]
				(if (not (nil? domain))
					(render-html-posts-helper (:blogid domain) request)
					(index-page)))))

	; "account urls"
	(GET templates/*permission-denied-uri* [] (permission-denied))
