Fork me on GitHub
Jon Johnson20:02:26

Hi everyone. I’m building a website using reagent + re-frame, and using reitit for routing. I’m having a little trouble understanding how to match query parameters passed through a URL into a path. I have a couple of routes setup as such:

(def routes
    {:name      :routes/home
     :view      views/home
     [{:start (fn [& params] (js/console.log "Entering home page"))
       :stop  (fn [& params] (js/console.log "Leaving home page"))}]}]
    {:name      :routes/search
     :view      views/results-panel
     :parameters {:query {:search {:term string?}}}
     :link-text "Search"
     [{:parameters {:query {:search :term}}
       :start (fn [] (re-frame/dispatch [::events/get-results :term]))}]}])
When I try passing a string matching the :routes/search path, it matches against the :routes/home path instead
(r/match-by-path routes "/?search=hello")
 => #reitit.core.Match{:template "/", :data {...}, :result nil, :path-params {}, :path "/", :query-params {:search "hello"}, :parameters {:path {}, :query {:search "hello"}}}
I feel like there’s something pretty simple here that I’m missing, though I’m not quite sure