Fork me on GitHub
#reitit
<
2020-07-21
>
Dave Simmons19:07:00

Hi All. This is hopefully a silly error I'm making but I'm trying to define a set of RESTful routes for an entity foo so I have "GET foo/new" to retrieve an empty form and "GET foo/:id" to retrieve a specific foo. Unfortunately this gives me a conflicting route path error when I define it in reitit. I'm sure I'm doing something daft but does someone have an example of a set of RESTful routes defined in reitit I could look at? cheers

byrongibby20:07:50

"foo/new" matches the path "foo/:id" so when you try retrieve an empty form, reitit may legitimately return the specific foo with :id=new, hence the conflict.

byrongibby20:07:18

You could possibly change your endpoints to "GET new/foo" and "GET foo/:id"

Dave Simmons20:07:36

thanks @U9KLJ8N0Z - makes sense - do you know a way around this or does reitit not really handle traditional REST routes? cheers

byrongibby21:07:26

I am learning web dev from scratch in Clojure, so unfortunately I have no experience in other languages (so its all traditional to me 🙂). You can apparently ignore conflicts by adding:

:conflicting true
to the route data of both https://metosin.github.io/reitit/basics/route_conflicts.html.

Dave Simmons22:07:52

thanks @U9KLJ8N0Z I've done web dev in a number of languages and Clojure is my absolute favourite. cheers

byrongibby20:07:34

I am still learning how content negotiation works, generally and in Clojure. I would like to use Muuntaja with Reitit to decode and encode to and from https://clojure.github.io/data.xml/ Element defrecords, is this possible? Or can one only decode and encode to and from regular Clojure maps?