reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
MikeE 2021-05-21T16:09:33.015900Z

Hi all - new to reitit and curious about route conflicts. I have a very standard REST API with two routes:

GET /api/communities
POST /api/communities 

MikeE 2021-05-21T16:09:48.016200Z

Reitit is reporting that this is a conflict. Do the HTTP verbs not uniquely identify the routes?

MikeE 2021-05-21T16:12:09.017400Z

Being new to this though maybe I just don’t have my route data structures setup correctly.. this is what I have

["/api"
   ["/communities"
    {:get {:summary    "Get list of communities"
           :parameters {}
           :response   {200
                        {:body communities-api-shape}}
           :handler    handler/communities-handler}}]
   ["/communities"
    {:post {:summary    "Create a new community"
           :parameters {:body communities-api-shape}
           :response   {200
                        {:body string?}}
           :handler    handler/create-community-handler}}]

dharrigan 2021-05-21T16:13:58.018Z

you normally just put it under one route, have a look here:

dharrigan 2021-05-21T16:14:25.018200Z

<https://github.com/dharrigan/startrek/blob/master/src/startrek/base/api/starship/routes.clj>

dharrigan 2021-05-21T16:14:43.018700Z

notice how get and post (and delete and patch) are all nested under the route

dharrigan 2021-05-21T16:15:24.018900Z

Maybe that might help πŸ™‚

MikeE 2021-05-21T16:17:02.019200Z

ah! thank you!

dharrigan 2021-05-21T16:17:47.019400Z

you're most welcome πŸ™‚

MikeE 2021-05-21T16:32:02.019600Z

that fixed it πŸ™‚

dharrigan 2021-05-21T16:41:02.019800Z

:thumbsup: