Fork me on GitHub
#reitit
<
2019-02-28
>
levitanong07:02:54

can one add coercion via custom expanders? Iā€™m trying to keep my routes code-free (i.e. data only), so I can store them in EDN files.

ikitommi09:02:52

interesting @levitanong. You could do that, or if you have just one coercion per app, you can set it in a router:

(ring/router
  my-routes-from-edn
  {:data {:coercion spec-coercion}})

ikitommi09:02:11

the :data gets merged to all routes.

ikitommi11:02:19

The new Trie is merged into master. Was fun optimizing the internals - now 20x faster than the original (Pedestal) version.

šŸŽ‰ 5
levitanong12:02:31

I went ahead and made the custom expander and I'm happy to report that it works. However your method is much more pleasing to me, so I'll go with that. :) thanks!

šŸ‘ 5
ikitommi13:02:43

so, we stuffed routes into a PersistenHashMap, which for sure, lost the order. The new code forces the routes into a PersistentArrayMap, which has the order. It might be lost again in json-serialization, but might also just work.

ikitommi13:02:32

there is [metosin/reitit "0.3.0-SNAPSHOT"] to test that (among others)

vinurs13:02:32

@ikitommi thanks very much, i tested it just now, it works ok

šŸ‘ 5
kanwei16:02:40

["/{šŸŒˆ}:thinking_face:/šŸŽˆ" ::emoji] next level

levitanong17:02:37

@ikitommi testing 0.3.0.

(r/match-by-name (r/router [["" :google]]) :google)

;; #reitit.core.PartialMatch{:template "", :data {:name :google}, :result nil, :path-params nil, :required #{:}}
Seems like an odd match

ikitommi19:02:50

@levitanong really odd match indeed :)