Fork me on GitHub
#luminus
<
2017-04-13
>
juliobarros04:04:03

Thank you @yogthos I’ll give that a try.

yogthos12:04:08

let me know how it goes 🙂

ikitommi14:04:19

hi, there is an easier way to setup the params for Muuntaja. All formats have optional :encoder-opts and :decoder-opts that get merged into the default opts. So, a assoc-in would do here.

ikitommi14:04:58

here’s a sample from Muuntaja README:

(-> (muuntaja/create
      (assoc-in
        muuntaja/default-options
        [:formats "application/edn" :decoder-opts]
        {:readers {'INC inc}}))
    (muuntaja/decode
      "application/edn"
      "{:value #INC 41}")); {:value 42}

ikitommi14:04:43

I think transit-example would be good too, thanks for the tip. The responses.md is awesome.

ikitommi14:04:10

One idea for Luminus: mount (and configure) the Muuntaja instance with mount and just pass the instance to the wrap-params. The mw takes either an Muuntaja instance or options (and creates the instance itself). Having a app-level instance available makes the encoding & decoding symmetric. e.g. you can use the instance to encode stuff downstream with same settings. e.g. write custom transit to log/db etc.

ikitommi14:04:36

so, I think this should work (as the default handlers-map is empty with transit, I believe):

(assoc-in
  m/default-options
  [:formats "application/transit+json" :encoder-opts] 
  {:handlers {org.joda.time.DateTime joda-time-writer}})

yogthos19:04:59

ah thanks for the tip 🙂

yogthos19:04:51

that's definitely cleaner