Fork me on GitHub
#figwheel-main
<
2019-02-10
>
kwladyka20:02:33

(defn handler [request]
  (if (and (= :get (:request-method request))
           (= "/"  (:uri request)))
    {:status 200
     :headers {"Content-Type" "text/html"}
     :body "home"}
    {:status 404
     :headers {"Content-Type" "text/plain"}
     :body "Not Found!!!"}))
with :ring-handler server/handler Handler works, because I see “Not Found!!!“, but when open localhost:9500 I see normal index.html from resources. How…? How does it work? How magic work? This handler doesn’t provide index.html.

kwladyka20:02:06

figwheel-main add additional layer and this handler in fired only when file is not found or something?

kwladyka20:02:19

documentation says nothing about this

kwladyka20:02:08

on the end my purpose is to develop SPA with HTML5 routes using accountant. So I need ring server to return index.html instead

kwladyka20:02:16

hmm ok it looks like figwheel-main add additional middleware which on the first place load files if they exist

kwladyka20:02:47

Do you know where is code in fighweel-main with this middleware (or whatever it is)?

kwladyka20:02:13

(defn handler [request]
  (resource-response "index.html" {:root "public"}))
so i end with this

kwladyka20:02:53

example in documentation doesn’t seem to be relevant to how figwheel-main works

kwladyka20:02:24

/ path is never loaded, because index.html is on top of it even when it is not defined in handler