Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e49811889 | ||
|
|
c90907fa63 |
3 changed files with 11 additions and 21 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -16,3 +16,4 @@ doo-index.html
|
||||||
/.idea
|
/.idea
|
||||||
/.lein-repl-history
|
/.lein-repl-history
|
||||||
/.nrepl-history
|
/.nrepl-history
|
||||||
|
clojurescript.js
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,15 @@
|
||||||
(ns app.www
|
(ns app.www
|
||||||
(:require [app.nyse :refer [add-order find-orders create-nyse-schema]]
|
(:require [app.nyse :refer [add-order find-orders create-nyse-schema]]
|
||||||
[app.conf :refer [config]]
|
|
||||||
[mount.core :refer [defstate]]
|
[mount.core :refer [defstate]]
|
||||||
[cheshire.core :refer [generate-string]]
|
[cheshire.core :refer [generate-string]]
|
||||||
[compojure.core :refer [routes defroutes GET POST]]
|
[compojure.core :refer [routes defroutes GET]]))
|
||||||
[compojure.handler :as handler]
|
|
||||||
[ring.adapter.jetty :refer [run-jetty]]))
|
|
||||||
|
|
||||||
(defroutes mount-example-routes
|
(defroutes mount-example-routes
|
||||||
|
|
||||||
(GET "/" [] "welcome to mount sample app!")
|
(GET "/" [] "welcome to mount sample app!")
|
||||||
|
|
||||||
(GET "/nyse/orders/:ticker" [ticker]
|
(GET "/nyse/orders/:ticker" [ticker]
|
||||||
(generate-string (find-orders ticker)))
|
(generate-string (find-orders ticker))))
|
||||||
|
|
||||||
(POST "/nyse/orders" [ticker qty bid offer]
|
(defstate nyse-app :start (do (create-nyse-schema)
|
||||||
(add-order ticker (bigdec bid) (bigdec offer) (Integer/parseInt qty))
|
(add-order "GOOG" 665.51M 665.59M 100)))
|
||||||
(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
|
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,15 @@
|
||||||
[com.datomic/datomic-free "0.9.5327" :exclusions [joda-time]]]
|
[com.datomic/datomic-free "0.9.5327" :exclusions [joda-time]]]
|
||||||
|
|
||||||
:plugins [[lein-cljsbuild "1.1.1"]
|
:plugins [[lein-cljsbuild "1.1.1"]
|
||||||
|
[lein-ring "0.9.7"]
|
||||||
[lein-doo "0.1.6"]
|
[lein-doo "0.1.6"]
|
||||||
[lein-figwheel "0.5.0-2"]
|
[lein-figwheel "0.5.0-2"]
|
||||||
[test2junit "1.1.3"]]
|
[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")
|
:test2junit-output-dir ~(or (System/getenv "CIRCLE_TEST_REPORTS") "target/test2junit")
|
||||||
|
|
||||||
:clean-targets ^{:protect false} [:target-path
|
:clean-targets ^{:protect false} [:target-path
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue