Fork me on GitHub
#yada
<
2017-03-27
>
lsnape08:03:58

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))

lsnape08:03:01

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.

malcolmsparks10:03:25

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

malcolmsparks10:03:49

Maybe others have other strategies.

lsnape13:03:29

Thanks Malcolm