Fork me on GitHub
#reitit
<
2023-03-02
>
wombawomba19:03:39

When using Reitit with the default Muuntaja middleware, how can I get Muuntaja to completely ignore a specific route (with a specific method)? (Specifically, I want the body to remain an InputStream, even if Muuntaja would normally decode it)

wombawomba19:03:14

FWIW from the documentation (https://cljdoc.org/d/metosin/reitit/0.5.18/api/reitit.ring.middleware.muuntaja) I figured I should be able to just add :muuntaja nil to the route, i.e.:

["/my-path"
 {:get ...
  :put {:muuntaja niL
        ...}}]
...but this seems to have had no effect

wombawomba19:03:22

I was able to get it working by setting :muuntaja to

(muuntaja/create
   (->> {:decode-request-body?  (constantly false)
         :encode-response-body? (constantly false)}
        (update muuntaja/default-options :http merge)))
...seems like there should be a simpler way though?

danielneal20:03:13

I understand malli request coercion, you take some json object and it gets coerced using the schema to edn data. The relevant decoders are called. But what happens with response coercion? It seems like more is going on and I’m struggling to get my head around it.

danielneal20:03:29

Does it get decoded using the default coercer, then validated, then encoded using the encoder of the format