reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
ikitommi 2020-08-14T04:40:06.018800Z

@ramblurr when a router is created, all nested paths are concatenated and route data is accumulated. Having an "" as path somewhere adds nothing visible in the (string) concatenation, so you can have as many of those. Only paths that don't have child paths are recognized as separate paths (before the or gets merged), so you might need to add a empty "" into the end of the path so it doesn't have child routes.

ikitommi 2020-08-14T04:40:52.019500Z

["/api"
 ["/admin" {:middleware [::admin]}
  ["" ::admin]
  ["/db" ::db]]
 ["/ping" ::ping]]
=>
[["/api/admin" {:middleware [::admin], :name ::admin}]
 ["/api/admin/db" {:middleware [::admin], :name ::db}]
 ["/api/ping" {:name ::ping}]]

Casey 2020-08-14T07:29:05.020100Z

thanks @ikitommi "Only paths that don't have child paths are recognized as separate paths" was the key to my understanding there.

👍 1
2020-08-14T09:58:11.031900Z

Hi everybody! I would be super grateful if somebody could point me in the right direction, I have searched the web but am unable to make it work. I am trying to create an little web app using reitit on the backend. During development I am using shadow-cljs for running the FE on port 3000, and http-kit/ring/reitit on port 4000 Later I want to deploy my little app by compiling it into an uberjar, and serve the FE (index.html, css and (cl)js) “though” the backend (perhaps not the correct terminology). I am thinking that the route “/” will serve my index.html. Perhaps I want some api-endpoints in the backend for instance “/api/getcandy” or something like that. Now to my routing-issue. My index.html lies under resources/public/index.html but when I go to the “home” route localhost:4000 or localhost/index.html i get 404. I have no clue how to debug this, I am thinking that I should be able to connect to running backend-repl and see stacktraces flying around but I dont know how.

2020-08-23T08:26:21.029900Z

@tkjone thank you very much I will look into your suggestion, much appreciated!

2020-08-14T09:58:30.032400Z

Thanks in advance for any input! Greetings from Sweden / Adam

2020-08-14T09:59:19.032600Z

here is some screenshots

athomasoriginal 2020-08-14T13:19:43.035300Z

Just read over this quickly and looked at your code image. Here is how I made all the front end routes hitting “/*” work: https://gist.github.com/athomasoriginal/14c6cfa1500bc1ab1a90a98b9d7217a0 Let me know if that helps 🙂

Casey 2020-08-14T13:28:32.035600Z

@tkjone strikes again!

😆 1
2020-08-14T17:47:22.036Z

What is the best way to set up CORS?

ikitommi 2020-08-16T18:25:26.037600Z

See https://github.com/metosin/reitit/issues/236