hi! I have upgraded from 1.x to 2.x and I am having issues with getting the body in some routes. It’s related to https://github.com/weavejester/compojure/wiki/Common-Problems . Before I had (middleware [[wrap-restful-params {:formats [:json :edn]}]] ...)
so all routes got the body. I tried (route-middleware [[wrap-restful-params {:formats [:json :edn]}]] ...)
since middleware was deprecated, but that did not do the trick.
what’s the new middleware I should use?
my setup is same as https://github.com/metosin/compojure-api/issues/206
@psalaberria002 2.x will use Muuntaja instead of ring-middleware-format, it’s 10x faster but with different config. There is a guide in Muuntaja how to set it up: https://github.com/metosin/muuntaja/wiki/Configuration.
If you want it with defaults, adding muuntaja.middleware/wrap-format
should do it.
I could update the wiki actually.
Just a sec.
awesome! that’s what I was looking for
@psalaberria002 https://github.com/metosin/compojure-api/wiki/2.0.0-Content-Negotiation-(with-Muuntaja)
I will give it a try.
still not working
am I missing something?
ooo I see now
Hmm…
in your docs you have a different way of declaring the middleware
I can’t recall what the route-middleware
does, but it’s just a vanilla ring middleware, so (wrap-format (routes route1 route2))
kind of thing should work I think.
it worked that way
great!
thanks for the help
and, you don’t have to say the :formats
in the apis, if you have defined before those. Doesn’t matter but there can be many Muuntaja mws in the pipeline, first matching does the thing, others are no-op.
np, great to hear you got it working. someone needs to rewrite the docs before 2.0.0 can be pushed out…
btw, you have :format {:formats [:json :edn]}
under the :swagger
? I believe it doesn’t mean anything there.
I was just playing with it
I will remove it
ok, cool 🙂
I'm trying to figure out how to coerce my response specs in compoure-api, could someone take a look and point me in the right direction? https://stackoverflow.com/questions/46702269/compojure-api-spec-coercion-on-response-body
@bmabey hi, answered on the SO.
the gist was very helpful thanks!
Thanks! I had a follow-up question that I added there to keep the conversation in one place.
BTW, thanks for spec-tools and compojure-api!