A fast data-driven routing library for Clojure/Script
Find a file
Tommi Reiman 5646494388 Merge pull request #8 from metosin/PathFor
Lot's of small improvements
2017-08-10 15:23:42 +03:00
perf-test/clj/reitit Lot's of small improvements 2017-08-10 09:47:27 +03:00
scripts Initial commit 2017-08-07 14:15:45 +03:00
src/reitit Lot's of small improvements 2017-08-10 09:47:27 +03:00
test Lot's of small improvements 2017-08-10 09:47:27 +03:00
.gitignore Initial commit 2017-08-07 14:15:45 +03:00
.travis.yml Initial commit 2017-08-07 14:15:45 +03:00
CHANGELOG.md Initial commit 2017-08-07 14:15:45 +03:00
CONTRIBUTING.md Initial commit 2017-08-07 14:15:45 +03:00
LICENSE Initial commit 2017-08-07 14:15:45 +03:00
project.clj Add stuff 2017-08-08 15:31:00 +03:00
README.md Fix README 2017-08-09 10:36:57 +03:00

reitit Build Status Dependencies Status

Snappy data-driven router for Clojure(Script).

  • Simple data-driven route syntax
  • Generic, not tied to HTTP
  • Extendable
  • Fast

Latest version

Clojars Project

Usage

Named routes (example from bide).

(require '[reitit.core :as reitit])

(def router
  (reitit/router
    [["/auth/login" :auth/login]
     ["/auth/recovery/token/:token" :auth/recovery]
     ["/workspace/:project-uuid/:page-uuid" :workspace/page]]))

(reitit/match-route router "/workspace/1/2")
; {:name :workspace/page
;  :route-params {:project-uuid "1", :page-uuid "2"}}

Nested routes with meta-merged meta-data:

(def handler (constantly "ok"))

(def ring-router
  (reitit/router
    ["/api" {:middleware [:api]}
     ["/ping" handler]
     ["/public/*path" handler]
     ["/user/:id" {:parameters {:id String}
                   :handler handler}]
     ["/admin" {:middleware [:admin] :roles #{:admin}}
      ["/root" {:roles ^:replace #{:root}
                :handler handler}]
      ["/db" {:middleware [:db]
              :handler handler}]]]))

(reitit/match-route ring-router "/api/admin/db")
; {:middleware [:api :admin :db]
;  :roles #{:admin}
;  :handler #object[...]
;  :route-params {}}

Special thanks

To all Clojure(Script) routing libs out there, expecially to Ataraxy, Bide, Bidi, Compojure and Pedestal.

License

Copyright © 2017 Metosin Oy

Distributed under the Eclipse Public License, the same as Clojure.