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 :coll :id-key :id}] ["/user/{id}" {:name :user ::ns :my-app.endpoint.user ::type :ent :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 :coll :ctx {:foo :bar} :id-key :id}] ["/user/{id}" {:name :user ::ns :my-app.endpoint.user ::type :ent :ctx {:foo :bar} :id-key :id}] ["/post" {:name :posts ::ns :my-app.endpoint.post ::type :coll :ctx {:foo :bar} :id-key :id}] ["/post/{id}" {:name :post ::ns :my-app.endpoint.post ::type :ent :ctx {:foo :bar} :id-key :id}]
;; vote routes do not include the :ctx key ["/vote" {:name :votes ::ns :my-app.endpoint.vote ::type :coll :id-key :id}] ["/vote/{id}" {:name :vote ::ns :my-app.endpoint.vote ::type :ent :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 :coll
:id-key :id}]
["/user/{id}" {:name :user
::ns :my-app.endpoint.user
::type :ent
: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 :coll
:ctx {:foo :bar}
:id-key :id}]
["/user/{id}" {:name :user
::ns :my-app.endpoint.user
::type :ent
:ctx {:foo :bar}
:id-key :id}]
["/post" {:name :posts
::ns :my-app.endpoint.post
::type :coll
:ctx {:foo :bar}
:id-key :id}]
["/post/{id}" {:name :post
::ns :my-app.endpoint.post
::type :ent
:ctx {:foo :bar}
:id-key :id}]
;; vote routes do not include the :ctx key
["/vote" {:name :votes
::ns :my-app.endpoint.vote
::type :coll
:id-key :id}]
["/vote/{id}" {:name :vote
::ns :my-app.endpoint.vote
::type :ent
:id-key :id}]]cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |