Fork me on GitHub

Another bidi question incoming: I would like to share my routes with some clojurescript client code, either by sharing it in a cljc file, or passing the routes in the config map when the page initialises (haven’t decided yet). The only realistic way I see of achieving this is to have the handlers in the routes as keywords, and then have an extra lookup from the resource handlers from the keywords:

(def routes
  {"/foo" :bar})

(def handler->fn
  {:bar (yada "bar")})

(let [{:keys [handler]} (match-route route "/foo")]
  (get handler->fn handler))


Is there a more concise way of doing this? Ideally I’d like to lose the handler->fn. One idea I had was to use tag and postwalk to extract the tags at the leaves.


Both approaches are fine. Quite sensible to use keywords and postwalk


Maybe others have other strategies.


Thanks Malcolm