Fork me on GitHub
#reitit
<
2018-06-11
>
ikitommi17:06:17

glad you like it! feeback most welcome, on anything or on the roadmap/issues.

yogthos21:06:06

it might be handy to add some helpers for matching routes, and extracting params, for example we've got these sort of things going for cljs at work:

(defn match-route [uri]
  (->> (or (not-empty (string/replace uri #"^.*#" "")) "/")
       (reitit/match-by-path router)))

(defrecord ReititRouter [routes]
  api/Router
  (data->url [_ [route-name path-params]] (str (:path (reitit/match-by-name routes route-name path-params))
                           (when-some [q (:query-string path-params)] (str "?" q))
                           (when-some [h (:hash path-params)] (str "#" h))))
  (url->data [_ url] (let [[path+query fragment] (string/split url #"#" 2)
                           [path query] (string/split path+query #"\?" 2)]
                       (some-> (reitit/match-by-path routes path)
                               (assoc :query-string query :hash fragment)))))

yogthos21:06:41

seems like it would be a common use case on the client