Last active
September 22, 2021 16:25
-
-
Save tmattacchione/14c6cfa1500bc1ab1a90a98b9d7217a0 to your computer and use it in GitHub Desktop.
Revisions
-
tmattacchione revised this gist
Aug 12, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -41,7 +41,7 @@ ((reitit.ring/ring-handler (router) (reitit.ring/routes (spa-fallback-handler) (reitit.ring/create-default-handler)))))) (comment -
tmattacchione revised this gist
Jul 28, 2020 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,8 +46,15 @@ (comment ;; using option 1 (app {:request-method :get :uri "/ping"}) ; => {:status 200, :body "pong"} (app {:request-method :get :uri "/"}) ; => {:status 302, :headers {"Location" "/index.html"}, :body ""} (app {:request-method :get :uri "/public/index.html"}) ; => {:status 200, :headers {"Content-Length" "667" ... "Content-Type" "text/html"}, :body ..."]} ;; using option 2 (app {:request-method :get :uri "/ping"}) ; => {:status 200, :body "pong"} (app {:request-method :get :uri "/"}) ; => {:status 200, :headers {"Content-Length" "667" ... "Content-Type" "text/html"}, :body ..."]} (app {:request-method :get :uri "/public/index.html"}) ; => {:status 200, :headers {"Content-Length" "667" ... "Content-Type" "text/html"}, :body ..."]} (app {:request-method :get :uri "/login"}) ; => {:status 200, :headers {"Content-Length" "667" ... "Content-Type" "text/html"}, :body ..."]} :end) -
tmattacchione revised this gist
Jul 28, 2020 . 1 changed file with 19 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ (ns app (:require [reitit.ring]) [ring.util.response :as response] (defn secret-route @@ -11,13 +13,20 @@ [] ["public/*" (reitit.ring/create-resource-handler)])]) (defn spa-fallback-handler [] (fn [request] (or (response/resource-response (:uri request) {:root "public"}) (-> (response/resource-response "index.html" {:root "public"}) (response/content-type "text/html"))))) (defn router [] (reitit.ring/router [(public-resource-route) (secret-route)])) ;; option 1 - doesn't seem to work (defn app [req] (-> req ((reitit.ring/ring-handler @@ -26,6 +35,15 @@ (reitit.ring/create-resource-handler {:path "/"}) (reitit.ring/create-default-handler)))))) ;; option 2 - works (defn app [req] (-> req ((reitit.ring/ring-handler (router) (reitit.ring/routes (spa-fallback-handler {:path "/"}) (reitit.ring/create-default-handler)))))) (comment (app {:request-method :get :uri "/ping"}) ; => {:status 200, :body "pong"} -
tmattacchione revised this gist
Jul 25, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,7 @@ (comment (app {:request-method :get :uri "/ping"}) ; => {:status 200, :body "pong"} (app {:request-method :get :uri "/"}) ; => {:status 302, :headers {"Location" "/index.html"}, :body ""} (app {:request-method :get :uri "/public/index.html"}) ; => {:status 200, :headers {"Content-Length" "667" ... "Content-Type" "text/html"}, :body ..."]} -
tmattacchione revised this gist
Jul 25, 2020 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,5 +30,6 @@ (app {:request-method :get :uri "/"}) ; => {:status 200, :body "pong"} (app {:request-method :get :uri "/"}) ; => {:status 302, :headers {"Location" "/index.html"}, :body ""} (app {:request-method :get :uri "/public/index.html"}) ; => {:status 200, :headers {"Content-Length" "667" ... "Content-Type" "text/html"}, :body ..."]} :end) -
tmattacchione revised this gist
Jul 25, 2020 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,3 +25,10 @@ (reitit.ring/routes (reitit.ring/create-resource-handler {:path "/"}) (reitit.ring/create-default-handler)))))) (comment (app {:request-method :get :uri "/"}) ; => {:status 200, :body "pong"} (app {:request-method :get :uri "/"}) ; => {:status 302, :headers {"Location" "/index.html"}, :body ""} ) -
tmattacchione revised this gist
Jul 25, 2020 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,4 +23,5 @@ ((reitit.ring/ring-handler (router) (reitit.ring/routes (reitit.ring/create-resource-handler {:path "/"}) (reitit.ring/create-default-handler)))))) -
tmattacchione created this gist
Jul 25, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ (ns app (:require [reitit.ring]) (defn secret-route [] ["/secret" {#_ ...stuff}]) (defn public-resource-route [] ["public/*" (reitit.ring/create-resource-handler)])]) (defn router [] (reitit.ring/router [(public-resource-route) (secret-route)])) (defn app [req] (-> req ((reitit.ring/ring-handler (router) (reitit.ring/routes (reitit.ring/create-resource-handler {:path "/"}))))))