This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-14
Channels
- # announcements (3)
- # babashka (189)
- # beginners (157)
- # calva (5)
- # cider (5)
- # clj-kondo (7)
- # cljdoc (34)
- # clojure (61)
- # clojure-dev (2)
- # clojure-europe (42)
- # clojure-nl (15)
- # clojure-poland (1)
- # clojure-spec (5)
- # clojure-uk (6)
- # clojured (2)
- # clojurescript (31)
- # clojureverse-ops (8)
- # component (2)
- # cursive (41)
- # datomic (15)
- # depstar (44)
- # figwheel-main (9)
- # fulcro (14)
- # holy-lambda (1)
- # inf-clojure (13)
- # introduce-yourself (1)
- # jobs (1)
- # lsp (98)
- # malli (12)
- # off-topic (12)
- # pedestal (1)
- # polylith (3)
- # re-frame (51)
- # reitit (4)
- # releases (1)
- # reveal (5)
- # shadow-cljs (3)
- # tools-deps (56)
- # vim (12)
- # xtdb (36)
Is there a way to specifiy route aliases in reitit? e.g.:
{"/api/objectives" "/api/concepts/objectives"
"/api/risk-source" "/api/concepts/risk-source"}
You could make a var api-routes
with two entries for "/objectives" and "/risk-source" and attach it like this ["/api" ["" api-routes "/concepts" api-routes]]
Don’t define the router data in one glob and you’re good to go 🙂
What I tend to do is that if I have eg. a REST resource collection, I define all of its operations in a single namespace with just the relevant path. So I might have like GET /restaurants
, GET /restaurants/{restaurantId}/menu
etc. with all the handlers and needed glue in one namespace and at the bottom of it usually a (def routes ["/:restaurantId" {:get handler} ...])
where I create a sort of subrouter, and in my actual router definition I just require those routes and put them together;
(def all-routes (ring/router ["/api" ["/v1" ["/restaurants" restaurants-controller/routes] ...]]))
this way I can mount the same thing in multiple places, compose the routes, have some fine grained and more local source to what route comes from where etc. etc.
I hope that explanation made sense. YMMV 🙂