Fork me on GitHub
#reitit
<
2020-04-29
>
Spaceman05:04:52

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?

rschmukler15:04:18

@pshar10 you probably need to call rfe/start! so that rfe's router atom gets set

Marcus19:04:14

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

manutter5120:04:56

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

manutter5120:04:08

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 😄 )