adding lein-ring :handler/:init example
This commit is contained in:
parent
23b0f70927
commit
c90907fa63
3 changed files with 10 additions and 17 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
|
||||||
|
|
|
||||||
|
|
@ -10,22 +10,9 @@
|
||||||
(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