File tree Expand file tree Collapse file tree 1 file changed +16
-18
lines changed
src/main/clojure/cljs/repl Expand file tree Collapse file tree 1 file changed +16
-18
lines changed Original file line number Diff line number Diff line change 24
24
(def ^:dynamic ordering nil )
25
25
(def ^:dynamic es nil )
26
26
27
+ (def ext->mime-type
28
+ {" .html" " text/html"
29
+ " .css" " text/css"
30
+
31
+ " .jpg" " image/jpeg"
32
+ " .png" " image/png"
33
+ " .gif" " image/gif"
34
+
35
+ " .js" " text/javascript"
36
+ " .cljs" " text/x-clojure"
37
+ " .cljc" " text/x-clojure"
38
+ " .map" " application/json" })
39
+
27
40
(defn- set-return-value-fn
28
41
" Save the return value function which will be called when the next
29
42
return value is received."
84
97
local-path)]
85
98
(if local-path
86
99
(server/send-and-close conn 200 (slurp local-path)
87
- (condp #(.endsWith %2 %1 ) path
88
- " .html" " text/html"
89
- " .css" " text/css"
90
- " .html" " text/html"
91
- " .jpg" " image/jpeg"
92
- " .js" " text/javascript"
93
- " .cljs" " text/x-clojure"
94
- " .cljc" " text/x-clojure"
95
- " .map" " application/json"
96
- " .png" " image/png"
100
+ (if (some #(.endsWith path %) (keys ext->mime-type))
101
+ (get ext->mime-type path)
97
102
" text/plain" ))
98
103
(server/send-404 conn path)))
99
104
(server/send-404 conn path)))
105
110
106
111
(server/dispatch-on :get
107
112
(fn [{:keys [path]} _ _]
108
- (or
109
- (= path " /" )
110
- (.endsWith path " .js" )
111
- (.endsWith path " .cljc" )
112
- (.endsWith path " .cljs" )
113
- (.endsWith path " .map" )
114
- (.endsWith path " .html" )
115
- (.endsWith path " .css" )))
113
+ (or (= path " /" ) (some #(.endsWith path %) (keys ext->mime-type))))
116
114
send-static)
117
115
118
116
(defmulti handle-post (fn [m _ _ ] (:type m)))
You can’t perform that action at this time.
0 commit comments