This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-01-06
Channels
- # announcements (18)
- # asami (3)
- # aws (10)
- # babashka (47)
- # beginners (343)
- # calva (36)
- # cider (4)
- # clojure (66)
- # clojure-europe (9)
- # clojure-nl (3)
- # clojure-uk (23)
- # clojurescript (30)
- # community-development (69)
- # conjure (1)
- # eastwood (9)
- # events (7)
- # fulcro (81)
- # graalvm (1)
- # malli (5)
- # meander (1)
- # off-topic (41)
- # pathom (15)
- # rdf (1)
- # reitit (6)
- # sci (57)
- # shadow-cljs (18)
- # spacemacs (4)
- # startup-in-a-month (1)
- # testing (2)
- # vim (1)
I'm doing my first steps with reitit and get errors about route conflicts, the documentation talks about various features regarding route conflicts, but I couldn't find an explanation on what is a route conflict. What is the conflict between :
["/public/*path"]
and
["/:version/status"]
They seem completely different.
From searching google, looks like this term is not that commonly used.@ozfraier /:version
will also match /public
since reitit just sees a string matching :version
. As long as you have /public
first, it will match first and everything will work as you expect (where "/v3/status"
or whatever won't match /public
and match the parameterized route further down the line. You can use {:conflicting true}
to get past this, as per: https://cljdoc.org/d/metosin/reitit/0.5.10/doc/basics/route-conflicts ...which I found by googling "reitit route conflict". 😉
@ozfraier Two thoughts:
(1) The reitit docs look intimidating at first, but they're actually just surprisingly comprehensive. Reitit is a rather small and polite library but in my experience it has always done exactly what I've wanted it to do... once I read the docs and understand what I'm looking for.
(2) You probably don't want to parameterize the inner portions of your routes, if you can help it. I'd suggest "/status/:version"
in the example you gave.
Thank you @steven427, I actually took the example from the same page you linked, I admit, I wasn't super sharp thinking why the routes in the example are conflicting, the docs treat this as a given, and it is very logical after you explained it. maybe just a small hint like : "routes conflict when the same path, e.g "public/status" can match different routes:" can be helpful. My real world conflict turns out to be: "/projects/:project" and "/projects/new" and reitit is smart to point it out.
Yup, I have quite a few of that exact conflict (`"/:id" vs. "/new"`) which led me to asking the same questions a couple months ago. 🙂 At one point, @ikitommi mentioned this to me:
the conflict resolver could be smarter and know that
[["/kikka/kikka"]
["/kikka/:id"]]
actually is not conflicting as the fixed term(s) comes first. PR welcome :)
...Clojure isn't my day job, so I haven't attempted that patch. @ozfraier If you're ever in the mood, you could give it a shot. 🙂