/
web.clj
55 lines (45 loc) · 1.5 KB
/
web.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(ns pinkgorilla.web
(:require
[clj-time.core :as t]
[luminus.http-server :as http]
[reitit.ring :as ring]
[ring.util.http-response :as response]
[ring.util.response :as res]
[ring.middleware.content-type :refer [wrap-content-type]]
[compojure.core :refer :all]
[compojure.route :as route]
[pinkgorilla.middleware :as middleware]
[pinkgorilla.bundle-info :refer [available-bundles bundle-details]]))
(defn bundle-link [bundle]
(str "<br/> <a href='/info?bundle=" bundle "'> " bundle "</a>"))
(defn summary []
(str "Available Bundles: "
(clojure.string/join " \n" (map bundle-link (available-bundles)))
; (pr-str (available-bundles))
"<br/>"
(t/time-now)))
(defn bundle-info [bundle]
{:status 200
:headers {"Content-Type" "text/plain"}
:body (str
"Bundle Details " bundle "\n"
(with-out-str (clojure.pprint/pprint (bundle-details bundle)))
;(pr-str (bundle-details bundle))
)})
(defroutes handler
(route/files "/out/public/cljs-runtime" {:root "out/public/cljs-runtime"})
(GET "/" [] (summary))
(GET "/info" [bundle] (bundle-info bundle))
(GET "/test" [] {:status 200
:headers {"Content-Type" "text/plain"}
:body "Hello \nWorld"})
(route/not-found "<h1>Page not found</h1>"))
(def app
(middleware/wrap-middleware handler))
(defn run-web []
(println "starting shadowdeps server at port 2705..")
(http/start
{:handler app
:port 2705}))
(comment
(run-web))