- Notifications
You must be signed in to change notification settings - Fork261
A fast data-driven routing library for Clojure/Script
License
metosin/reitit
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
- Simple data-drivenroute syntax
- Routeconflict resolution
- First-classroute data
- Bi-directional routing
- Pluggable coercion (malli,schema &clojure.spec)
- Helpers forring,http,pedestal &frontend
- FriendlyError Messages
- Extendable
- Modular
- Fast
Presentations:
- Reitit, The Ancient Art of Data-Driven, Clojure/North 2019,video
- Faster and Friendlier Routing with Reitit 0.3.0
- Welcome Reitit 0.2.0!
- Data-Driven Ring with Reitit
- Reitit, Data-Driven Routing with Clojure(Script)
Status:stable
Hi! We areMetosin, a consulting company. These libraries have evolved out of the work we do for our clients.We maintain & develop this project, for you, for free. Issues and pull requests welcome!However, if you want more help using the libraries, or want us to build something as cool for you, consider ourcommercial support.
There is#reitit inClojurians Slack for discussion & help.
metosin/reitit- all bundledmetosin/reitit-core- the routing coremetosin/reitit-ring- aring routermetosin/reitit-middleware-common middlewaremetosin/reitit-specclojure.spec coercionmetosin/reitit-mallimalli coercionmetosin/reitit-schemaSchema coercionfi.metosin/reitit-openapiOpenAPI apidocs *metosin/reitit-swaggerSwagger2 apidocsmetosin/reitit-swagger-uiIntegratedSwagger UImetosin/reitit-frontendTools for frontend routingmetosin/reitit-httphttp-routing with Interceptorsmetosin/reitit-interceptors-common interceptorsmetosin/reitit-siepparisupport forSiepparimetosin/reitit-dev- development utilities
... * This is not a typo; the newreitit-openapi was released under the new, verifiedfi.metosin group. Existingmodules will continue to be released undermetosin for compatibility purposes.
reitit-pedestalsupport forPedestal
All main modules bundled:
[metosin/reitit"0.9.2"]Optionally, the parts can be required separately.
Reitit requires Clojure 1.11 and Java 11.
Reitit is tested with the LTS releases Java 11, 17 and 21.
(require '[reitit.core:as r])(defrouter (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; :path-params {}; :path "/api/ping"}(r/match-by-name router::order {:id2}); #Match{:template "/api/orders/:id",; :data {:name ::order},; :result nil,; :path-params {:id 2},; :path "/api/orders/2"}
A Ring routing app with input & output coercion usingdata-specs.
(require '[muuntaja.core:as m])(require '[reitit.ring:as ring])(require '[reitit.coercion.spec])(require '[reitit.ring.coercion:as rrc])(require '[reitit.ring.middleware.exception:as exception])(require '[reitit.ring.middleware.muuntaja:as muuntaja])(require '[reitit.ring.middleware.parameters:as parameters])(defapp (ring/ring-handler (ring/router ["/api" ["/math" {:get {:parameters {:query {:x int?,:y int?}}:responses {200 {:body {:total int?}}}:handler (fn [{{{:keys [x y]}:query}:parameters}] {:status200:body {:total (+ x y)}})}}]];; router data affecting all routes {:data {:coercion reitit.coercion.spec/coercion:muuntaja m/instance:middleware [parameters/parameters-middleware; decoding query & form params muuntaja/format-middleware; content negotiation exception/exception-middleware; converting exceptions to HTTP responses rrc/coerce-request-middleware rrc/coerce-response-middleware]}})))
Valid request:
(-> (app {:request-method:get:uri"/api/math":query-params {:x"1",:y"2"}}) (update:body slurp)); {:status 200; :body "{\"total\":3}"; :headers {"Content-Type" "application/json; charset=utf-8"}}
Invalid request:
(-> (app {:request-method:get:uri"/api/math":query-params {:x"1",:y"a"}}) (update:body jsonista.core/read-value)); {:status 400; :headers {"Content-Type" "application/json; charset=utf-8"}; :body {"spec" "(spec-tools.core/spec {:spec (clojure.spec.alpha/keys :req-un [:spec$8974/x :spec$8974/y]), :type :map, :leaf? false})"; "value" {"x" "1"; "y" "a"}; "problems" [{"via" ["spec$8974/y"]; "path" ["y"]; "pred" "clojure.core/int?"; "in" ["y"]; "val" "a"}]; "type" "reitit.coercion/request-coercion"; "coercion" "spec"; "in" ["request" "query-params"]}}
reitit-ringwith coercion, swagger and default middlewarereitit-frontend, the easy wayreitit-frontendwith Keechma-style controllersreitit-httpwith Pedestalreitit-httpwith Sieppari
All examples are inhttps://github.com/metosin/reitit/tree/master/examples
- Simple web application using Ring/Reitit and Integrant:https://github.com/PrestanceDesign/usermanager-reitit-integrant-example
- A simple Clojure backend using Reitit to serve up a RESTful API:startrek. Technologies include:
- https://www.learnreitit.com/
- Lipas, liikuntapalvelut:https://github.com/lipas-liikuntapaikat/lipas
- Implementation of the Todo-Backend API spec, using Clojure, Ring/Reitit and next-jdbc:https://github.com/PrestanceDesign/todo-backend-clojure-reitit
- Ping CRM, a single page app written in Clojure Ring, Reitit, Integrant and next.jdbc:https://github.com/prestancedesign/clojure-inertia-pingcrm-demo
Check out the full documentation!
Join#reitit channel inClojurians slack.
Roadmap is mostly written inissues.
- Existing Clojure(Script) routing libs, especially toAtaraxy,Bide,Bidi,calfpath,Compojure,Keechma andPedestal.
- Compojure-api,Kekkonen,Ring-swagger andYada and for ideas, coercion & stuff.
- Schema andclojure.spec for the validation part.
- httprouter for ideas and a good library to benchmark against
Copyright © 2017-2023Metosin Oy
Distributed under the Eclipse Public License, the same as Clojure.
About
A fast data-driven routing library for Clojure/Script
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
