clojure - Ring/Compojure serving index.html in subfolders? -


my ressources/public directory contain many subfolders , each 1 contain index.html. how set routes watch ".../" path recursively , return index.html without showing file in url?

one way explicitly set each route below i'm hoping not need define each path.

(get  "/" [] (resource-response "index.html" {:root "public"})) (get  "/foo" [] (resource-response "foo/index.html" {:root "public"})) ... 

a small modification ring wrap-resources middleware trick:

(defn wrap-serve-index-file   [handler root-path]   (fn [request]     (if-not (= :get (:request-method request))       (handler request)       (let [path (.substring (codec/url-decode (:uri request)) 1)             final-path (if (= \/ (or (last path) \/))                            (str path "index.html")                            path)]         (or (response/resource-response path {:root root-path})             (handler request)))))) 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -