reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
Dave Simmons 2020-07-21T19:37:00.315Z

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

byrongibby 2020-07-21T20:48:50.315100Z

"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.

byrongibby 2020-07-21T20:54:34.318800Z

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?

byrongibby 2020-07-21T20:56:18.318900Z

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

Dave Simmons 2020-07-21T20:56:36.319100Z

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

byrongibby 2020-07-21T21:00:26.319300Z

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 Simmons 2020-07-21T22:03:52.319700Z

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