Fork me on GitHub
#reitit
<
2024-03-14
>
Linus Ericsson17:03:30

I got caught up on doing this today: ((reitit.ring/ring-handler (http://reitit.co/router ["/testpath" (fn [_] {:status 200 :body "ok"})])) {:request-method :get :uri "/testpath"}) => nil The error here is to use reitit.ring/router instead of reitit.core/router. I think this is somewhat a usability problem (which could be unique for only me), but would it somehow be possible for reitit.ring/ring-handler to deduce that the given router won't work as expected? Or - maybe more interesting - what is really the difference between reitit.core/router and reitit.ring/router?

wevrem20:03:48

I checked my project and I am using reitit.ring/router, which according to the documentation simply creates a reitit.core/Router. So there shouldn’t be any difference?

Linus Ericsson11:03:39

I'm using reitit 0.7.0-alpha7 and there is some difference between the two router functions there. In reitit.ring/router there is a transform that puts all handler functions in a :handler key for performance (which of course makes total sense). The strange thing was that I could not get it working even when I tried to be rigid about the structure of the handler fn.