Fork me on GitHub
#ring
<
2019-07-03
>
ivana15:07:10

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

seancorfield17:07:56

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

ikitommi18:07:05

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

ikitommi19:07:15

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