ring

2019-07-03T15:12:10.010Z

can anyone suggest me a usable way for parsing/unparsing bodies, params, etc on both requests and responses using ring middleware? I found out and tried some libraries https://github.com/ngrunwald/ring-middleware-format https://github.com/metosin/muuntaja/ https://github.com/ring-clojure/ring-json but noone was usable for me. Or maybe I can not prepare them rigth. For example, I have one handler and add all middlewares for it:

(def handler (-> routes
                     wrap-keyword-params
                     wrap-json-params
                     wrap-json-body
                     wrap-json-response))
and it shows an error java.lang.IllegalArgumentException: Cannot open <{"p" 1, "q" "22"}> as an InputStream

seancorfield 2019-07-03T17:28:56.010800Z

@ivana I don't think you can have both wrap-json-params and wrap-json-body -- the docs indicate they are alternatives.

ikitommi 2019-07-03T18:59:05.013600Z

(-> routes muuntaja.middleware/wrap-format)
should work. handles all of json, edn & transit. Your error suggest you have multiple formatters in the chain.

ikitommi 2019-07-03T19:00:15.015400Z

ring is not the easiest to debug the mw chain, what mws are there and how they transform the request & response