ngrunwald / ring-middleware-format

Ring middleware for parsing parameters and emitting responses in JSON or other formats
163 stars 49 forks source link

How to extend the Transit writer to support more types? #59

Closed theronic closed 8 years ago

theronic commented 8 years ago

I need to support writing org.joda.time.DateTime to transit. How would I extend the Transit writer used by the middleware?

Deraen commented 8 years ago

Something like this: https://gist.github.com/Deraen/eb3f650c472fb1abe970#file-transit-cljc

And by providing options to the middleware (example from Compojure-api but should give idea for other uses):

(api
  {:format {:params-opts   {:transit-json {:handlers transit-dates/readers}}
            :response-opts {:transit-json {:handlers transit-dates/writers}}}}
  ...)
Deraen commented 8 years ago

Closing this as there should be no problem here.