Routing and dispatching is in the core of most business apps, so we should have a great library to for it. There are already many good routing libs for Clojure, but we felt none was perfect. So, we took best parts of existing libs and added features that were missing: first-class composable route data, full route conflict resolution and pluggable coercion. Goal was to make a data-driven library that works, is fun to use and is really, really fast.
You can join #reitit channel in Clojurians slack to discuss things. Known roadmap is mostly written in issues.
Bidi is an great and proven library for ClojureScript and we have been using it in many of our frontend projects. Both Reitit and Bidi are data-driven, bi-directional and work with both Clojure & ClojureScript. Here are the main differences:
Bidi:
(def routes
["/" [["auth/login" :auth/login]
[["auth/recovery/token/" :token] :auth/recovery]
["workspace/" [[[:project-uuid "/" :page-uuid] :workspace/page]]]]])
Reitit:
(def routes
[["/auth/login" :auth/login]
["/auth/recovery/token/:token" :auth/recovery]
["/workspace/:project-uuid/:page-uuid" :workspace/page]])
;; Route compilation was only marginally effective and hard to
;; debug. When bidi matching takes in the order of 30 micro-seconds,
;; this is good enough in relation to the time taken to process the
;; overall request.
Pedestal is an great and proven library and has had great influence in Reitit. Both Reitit and Pedestal are data-driven and provide bi-directional routing and fast. Here are the main differences:
Pedestal:
["/api/ping" :get identity :route-name ::ping]
Reitit:
["/api/ping" {:get identity, :name ::ping}]
reitit-http
module will support them too).Reitit routing was originally based on Pedestal Routing an thus they same similar performance. For routing trees with both static and wildcard routes, Reitit is much faster thanks to it's mixed-router
algorithm.
Compojure is the most used routing library in Clojure. It's proven and awesome.
reitit-ring
resolves this with data-driven middlewareCompojure:
(defroutes routes
(wrap-routes
(context "/api" []
(GET "/users/:id" [id :<< as-int]
(ok (get-user id)))
(POST "/pizza" []
(wrap-log post-pizza-handler)))
wrap-api :secure))
reitit-ring
with reitit-spec
module:
(def routes
["/api" {:middleware [[wrap-api :secure]]}
["/users/:id" {:get {:parameters {:path {:id int?}}}
:handler (fn [{:keys [parameters]}]
(ok (get-user (-> parameters :body :id))))}
["/pizza" {:post {:middleware [wrap-log]
:handler post-pizza-handler}]]])
Reitit is much faster than Compojure.
Google Translate does a decent job pronouncing it (click the speaker icon on the left). The English expression rate it is a good approximation.
Can you improve this documentation? These fine people already did:
Tommi Reiman & Miikka KoskinenEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close