mirror of
https://github.com/metosin/reitit.git
synced 2025-12-17 00:11:11 +00:00
A fast data-driven routing library for Clojure/Script
clojureclojurescriptdata-drivenfrontendinterceptorsmetosin-activemiddlewarepedestalringroutingswagger
|
|
||
|---|---|---|
| perf-test/clj/reitit | ||
| scripts | ||
| src/reitit | ||
| test | ||
| .gitignore | ||
| .travis.yml | ||
| CHANGELOG.md | ||
| CONTRIBUTING.md | ||
| LICENSE | ||
| project.clj | ||
| README.md | ||
reitit

Snappy data-driven router for Clojure(Script).
- Simple data-driven route syntax
- Generic, not tied to HTTP
- Extendable
- Fast
Latest version
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.