This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-06-21
Channels
- # aws (2)
- # aws-lambda (1)
- # beginners (62)
- # cider (31)
- # cljs-dev (16)
- # cljsrn (8)
- # clojure (115)
- # clojure-greece (3)
- # clojure-israel (2)
- # clojure-italy (13)
- # clojure-nl (8)
- # clojure-russia (5)
- # clojure-spec (3)
- # clojure-uk (146)
- # clojurescript (108)
- # clojutre (5)
- # code-reviews (3)
- # cursive (48)
- # datomic (22)
- # editors (20)
- # emacs (7)
- # fulcro (16)
- # graphql (10)
- # mount (2)
- # off-topic (47)
- # onyx (22)
- # re-frame (100)
- # reagent (5)
- # reitit (7)
- # ring-swagger (6)
- # rum (5)
- # shadow-cljs (51)
- # specter (2)
- # tools-deps (95)
- # vim (10)
- # yada (7)
@arlicle hi. it’s all data, so you have at least two good options:
1) create the endpoints with a wrapper function, that adds the :option
, something like:
(defn endpoint [data]
(assoc data :options {:handler ...}))
["/api"
["/something" (endpoint {:get ...})]]
2) transform the routes and add the endpoints later:
(def router
(ring/router
["/api"
["/ping" {:get identity}]
["/pong" {:get identity}]]))
(defn router-with-options [router]
(ring/router
(map (fn [[path data]]
[path (assoc data :options identity)])
(r/routes router))
(r/options router)))
(router-with-options router)
e.g. the Router
can be reconstructed from another router, via r/routes
and r/options
. the route tree is flattened, so one doesn’t have to walk the routes to find the endpoint data. it’s in the second position in the vector. There are Specs for these too.