reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
Matheus Moreira 2020-05-29T10:37:46.018800Z

hello, all. i am learning to use reitit and want to build routes for a restfull service. i thought that something like:

["/api/resources"
 {:get {...}
  :put {...}}
 ["/:res-id"
  {:get {...}
   :patch {...}}]]
would generate 4 routes: GET/PUT /api/resources and GET/PATCH /api/resources/:res-id but found out that this is not the case, only the two last routes are generated. what is the proper way to create the 4 routes? should i flatten the routes myself or is there another way to build these hierarchical routes?

ikitommi 2020-05-29T11:13:29.020300Z

@matheus.emm the intermediate path fragments are not counted as endpoints. There is a PR ongoing to change that. Before it, you need to define the endpoints like this:

["/api/resources"
 [""
  {:get {...}
   :put {...}}
 ["/:res-id"
  {:get {...}
   :patch {...}}]]

Matheus Moreira 2020-05-29T11:18:51.023600Z

@ikitommi, ok, understood. Maybe the documentation could be updated to make this point more obvious. When I read about this "empty" path I thought it was only to apply common data to a set of routes. Thanks for the clarification!

ikitommi 2020-05-29T11:19:31.024200Z

would you like to update the docs for this?

Matheus Moreira 2020-05-29T11:26:02.024400Z

sure 🙂