Fork me on GitHub

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 🙂


Thanks, both of you, for your help. I have a lot of these routes which are more complex than those shown in my example (as I’m sure you’ve guessed). Just trying to work out which is best in the context of my app… I will do a quick spike and try both. Thanks again 🙂