Sugar for reitit routes. Lets you:
/users
2b. a unary route, e.g. /user/{id}
A sugared route definition might be:
[[:my-app.endpoint.user]]
This would expand to:
[["/user" {:name :users ::ns :my-app.endpoint.user ::type :collection :id-key :id}] ["/user/{id}" {:name :user ::ns :my-app.endpoint.user ::type :member :id-key :id}]]
Here's how you'd apply a map of options to many routes:
[{:ctx {:foo :bar}} [:my-app.endpoint.user] [:my-app.endpoint.post]
{} ;; resets "shared" options to an empty ma [:my-app.endpoint.vote]]
This would expand to:
[["/user" {:name :users ::ns :my-app.endpoint.user ::type :collection :ctx {:foo :bar} :id-key :id}] ["/user/{id}" {:name :user ::ns :my-app.endpoint.user ::type :member :ctx {:foo :bar} :id-key :id}] ["/post" {:name :posts ::ns :my-app.endpoint.post ::type :collection :ctx {:foo :bar} :id-key :id}] ["/post/{id}" {:name :post ::ns :my-app.endpoint.post ::type :member :ctx {:foo :bar} :id-key :id}]
;; vote routes do not include the :ctx key ["/vote" {:name :votes ::ns :my-app.endpoint.vote ::type :collection :id-key :id}] ["/vote/{id}" {:name :vote ::ns :my-app.endpoint.vote ::type :member :id-key :id}]]
Sugar for reitit routes. Lets you: 1. Specify a map of options that apply to a group of routes 2. Transform names (usually namespace names) into reitit routes that include both: 2a. a collection routes, e.g. `/users` 2b. a unary route, e.g. `/user/{id}` ## Basic expansion A sugared route definition might be: [[:my-app.endpoint.user]] This would expand to: [["/user" {:name :users ::ns :my-app.endpoint.user ::type :collection :id-key :id}] ["/user/{id}" {:name :user ::ns :my-app.endpoint.user ::type :member :id-key :id}]] ## Common option map Here's how you'd apply a map of options to many routes: [{:ctx {:foo :bar}} [:my-app.endpoint.user] [:my-app.endpoint.post] {} ;; resets "shared" options to an empty ma [:my-app.endpoint.vote]] This would expand to: [["/user" {:name :users ::ns :my-app.endpoint.user ::type :collection :ctx {:foo :bar} :id-key :id}] ["/user/{id}" {:name :user ::ns :my-app.endpoint.user ::type :member :ctx {:foo :bar} :id-key :id}] ["/post" {:name :posts ::ns :my-app.endpoint.post ::type :collection :ctx {:foo :bar} :id-key :id}] ["/post/{id}" {:name :post ::ns :my-app.endpoint.post ::type :member :ctx {:foo :bar} :id-key :id}] ;; vote routes do not include the :ctx key ["/vote" {:name :votes ::ns :my-app.endpoint.vote ::type :collection :id-key :id}] ["/vote/{id}" {:name :vote ::ns :my-app.endpoint.vote ::type :member :id-key :id}]]
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close