Hi I'm trying to use the ring muuntaja wrapper in reitit and I noticed that when I don't supply a content type it goes through to the coercion layer. How do I tell it to reject unknown content types? Calling with with content-type foo also doesn't do anything.
I'd expect a status 415
Ended up with:
(defn enforce-content-type
[handler]
(fn [req]
(let [content-type (m/extract-content-type-ring req)]
(if (or (nil? content-type) (accepted-content-types content-type))
(cond-> req
(nil? content-type) (assoc-in
[:headers "content-type"]
(:default-format muuntaja-opts))
true handler)
(do
(log/warn "Unsupported content type requested"
{:content-type content-type})
(http-resp/unsupported-media-type
(util/error-response-body unacceptable-content-type-error)))))))I think what's happening is that muuntaja returns nil, but the coercion layer still tries to coerce
Looks like someone reported this: https://github.com/metosin/muuntaja/issues/133