From c90907fa63c5ecaeb1ee4506b7751fa55d798e1c Mon Sep 17 00:00:00 2001 From: anatoly Date: Sun, 27 Dec 2015 17:39:59 -0500 Subject: [PATCH] adding lein-ring :handler/:init example --- .gitignore | 1 + dev/clj/app/www.clj | 21 ++++----------------- project.clj | 5 +++++ 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index ded85c2..81a6a36 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ doo-index.html /.idea /.lein-repl-history /.nrepl-history +clojurescript.js diff --git a/dev/clj/app/www.clj b/dev/clj/app/www.clj index 2103d4e..1cfa616 100644 --- a/dev/clj/app/www.clj +++ b/dev/clj/app/www.clj @@ -10,22 +10,9 @@ (defroutes mount-example-routes (GET "/" [] "welcome to mount sample app!") + (GET "/nyse/orders/:ticker" [ticker] - (generate-string (find-orders ticker))) + (generate-string (find-orders ticker)))) - (POST "/nyse/orders" [ticker qty bid offer] - (add-order ticker (bigdec bid) (bigdec offer) (Integer/parseInt qty)) - (generate-string {:added {:ticker ticker - :qty qty - :bid bid - :offer offer}}))) - -(defn start-nyse [{:keys [www]}] - (create-nyse-schema) ;; creating schema (usually done long before the app is started..) - (-> (routes mount-example-routes) - (handler/site) - (run-jetty {:join? false - :port (:port www)}))) - -(defstate nyse-app :start (start-nyse config) - :stop (.stop nyse-app)) ;; it's a "org.eclipse.jetty.server.Server" at this point +(defstate nyse-app :start (do (create-nyse-schema) + (add-order "GOOG" 665.51M 665.59M 100))) diff --git a/project.clj b/project.clj index d852c23..5211673 100644 --- a/project.clj +++ b/project.clj @@ -25,10 +25,15 @@ [com.datomic/datomic-free "0.9.5327" :exclusions [joda-time]]] :plugins [[lein-cljsbuild "1.1.1"] + [lein-ring "0.9.7"] [lein-doo "0.1.6"] [lein-figwheel "0.5.0-2"] [test2junit "1.1.3"]] + :ring {:handler app.www/mount-example-routes + :init mount.core/start + :port 4242} + :test2junit-output-dir ~(or (System/getenv "CIRCLE_TEST_REPORTS") "target/test2junit") :clean-targets ^{:protect false} [:target-path