To test my app's routes, I'm using the reitit frontend, push-state function like so:
(rfe/push-state :home)
And my routes are:
(def router
(reitit/router
[["/" {:name :home
:view #'home
:controllers [{:start (fn [_] (rf/dispatch [:page/init-home]))}]}]
]))
But I get the error:
No protocol method Router.match-by-name defined for type null:
Why is that and what am I doing wrong?@pshar10 you probably need to call rfe/start!
so that rfe's router atom gets set
Does anyone know the best way to debug routes? I.e. I get http 500 but would like to acess a stack trace or someting
Check out the second argument to reitit.ring/router
. We have the following options at the top of the map:
:exception pretty/exception
;; uncomment the next line (and the matching require in `ns`) to get some really pretty diffs around each middleware call
;;:reitit.middleware/transform reitit-dev/print-request-diffs
That will print out some extensive debugging information for each request that comes thru (like, a LOT of info--which is why we keep it commented out when we’re not debugging routes 😄 )