I implemented a rudimentary slash-handler for my front-end. Front-end is an SPA, and there are places where the backend has to allow whatever *path , which negates the ring slash handler. So I'm doing this:
(defn start! []
(rfe/start!
(reitit/router routes {:conflicts nil})
#(rf/dispatch [::handle-navigate %]) ;; <--- on-navigate callback dispatches reframe navigation-handling event
...opts...))
(rf/reg-event-fx
::handle-navigate
(fn [{:keys [db]} [_ new-match]]
(let [href (.-href js/location)]
(if (str/ends-with? href "/") ;; <--- naïvely detect a trailing slash
{:fx [[::replace-href (subs href 0 (dec (count href)))]]}
{:db (assoc db ::route new-match ::controllers (some->> new-match (rfc/apply-controllers (::controllers db))))}))))
(rf/reg-fx
::replace-href
(fn [url] (.replace js/location url)))
I'm not planning on publishing url's with trailing slashes, and I use url-constructing functions everywhere, so I shouldn't be accidentally generating any. How needful will this be, maybe for the odd user who is attempting to type in a url from memory? But anyway, it works.