Permalink
Browse files

Don't run using Jetty directly, just expose ring handler

  • Loading branch information...
1 parent aaacef5 commit 4c9d624eb588bc963440be772246a7a4bca5d352 @bjeanes bjeanes committed May 5, 2012
Showing with 14 additions and 17 deletions.
  1. +1 −0 .gitignore
  2. +1 −3 bin/server
  3. +3 −3 project.clj
  4. +3 −4 src/bungle_o/core.clj
  5. +6 −7 src/bungle_o/webapp.clj
View
@@ -1,5 +1,6 @@
pom.xml
*jar
+*war
/native
/lib/
/classes/
View
@@ -1,4 +1,2 @@
#!/usr/bin/env bash
-
-export CLASSPATH="src:lib/*:$CLASSPATH"
-java -client -Xmx3000m clojure.main -e "(use 'bungle-o.webapp) (run)" $@
+lein run
View
@@ -1,11 +1,11 @@
(defproject bungle-o "1.0.0-SNAPSHOT"
:main bungle-o.core
+ :ring {:handler bungle-o.webapp/handler}
:description "FIXME: write description"
:dependencies [[compojure "1.0.1"]
[ring "1.0.2"]
- [org.clojure/clojure "1.4.0"]
+ [org.clojure/clojure "1.3.0"]
[org.clojure/data.zip "0.1.1"]
[org.clojure/data.xml "0.0.3"]
- [org.hornetq/hornetq-core "2.2.16.Final"]
- [org.jboss.netty/netty "3.2.7.Final"]]
+ [org.hornetq/hornetq-core "2.2.16.Final"]]
:plugins [[lein-beanstalk "0.2.2"]])
View
@@ -1,6 +1,5 @@
(ns bungle-o.core
- (:require [bungle-o.webapp :as web])
- (:gen-class :main true))
+ (:use ring.adapter.jetty)
+ (:require [bungle-o.webapp :as web]))
-(defn -main [& args]
- (web/run))
+(defn -main [& args] (run-jetty web/main-routes {:port 8080}))
View
@@ -1,11 +1,12 @@
(ns bungle-o.webapp
- (:use compojure.core, ring.adapter.jetty)
+ (:use compojure.core)
(:require [compojure.route :as route]
[clojure.java.io :as cio]
- [bungle-o.airbrake :as ab]))
+ [bungle-o.airbrake :as ab]
+ [compojure.handler]))
(defn slurp-stream [in]
- (slurp (java.io.InputStreamReader. in)))
+ (slurp (java.io.InputStreamReader. in)))
(defn prepare-message [body-stream]
(let [body (slurp-stream body-stream)]
@@ -17,10 +18,8 @@
(POST "/notifier_api/v2/notices/" [:as req]
(let [message (prepare-message (:body req))]
(if (:valid message)
- (println "VALID\n")
+ (println "VALID\n")
(println "INVALID\n"))))
(route/not-found "<h1>Page not found</h1>"))
-(defn run []
- (run-jetty main-routes {:port 8080}))
-
+(def handler (compojure.handler/api main-routes))

0 comments on commit 4c9d624

Please sign in to comment.