A friendly data-driven router for Clojure(Script).
- Simple data-driven route syntax
- Route conflict resolution
- First-class route data
- Bi-directional routing
- Ring-router with data-driven middleware
- Pluggable coercion (schema & clojure.spec)
- Extendable
- Modular
- Fast
See the full documentation for details.
All bundled:
[metosin/reitit "0.1.0-SNAPSHOT"]
Optionally, the parts can be required separately:
[metosin/reitit-core "0.1.0-SNAPSHOT"] ; just the router
[metosin/reitit-ring "0.1.0-SNAPSHOT"] ; ring-router
[metosin/reitit-spec "0.1.0-SNAPSHOT"] ; spec coercion
[metosin/reitit-schema "0.1.0-SNAPSHOT"] ; schema coercion
(require '[reitit.core :as r])
(def router
(r/router
[["/api/ping" ::ping]
["/api/orders/:id" ::order]]))
(r/match-by-path router "/api/ping")
; #Match{:template "/api/ping"
; :data {:name ::ping}
; :result nil
; :params {}
; :path "/api/ping"}
(r/match-by-name router ::order {:id 2})
; #Match{:template "/api/orders/:id",
; :data {:name ::order},
; :result nil,
; :params {:id 2},
; :path "/api/orders/2"}
Check out the full documentation!
Roadmap is mostly written in issues.
There is also a #reitit channel in Clojurians slack.
To all Clojure(Script) routing libs out there, expecially to Ataraxy, Bide, Bidi, Compojure and Pedestal.
Also to Compojure-api, Kekkonen, Ring-swagger and Yada and for ideas, coercion & stuff.
And, of course, to: Schema and clojure.spec.
The documentation is built with gitbook. To preview your changes locally:
npm install -g gitbook-cli
gitbook install
gitbook serve
To bump up version:
# new version
./scripts/set-version "1.0.0"
./scripts/lein-modules install
# works
lein test
# deploy to clojars
./scripts/lein-modules do clean, deploy clojars
Copyright © 2017 Metosin Oy
Distributed under the Eclipse Public License, the same as Clojure.