Closed tgetgood closed 10 years ago
This is expected behaviour. Ring stores the request body in an InputStream, which means that middleware that consumes the stream, such as wrap-json-body, is side-effectful.
The reason for this is that request bodies can be very large, and it's not feasible to read them into memory by default.
This may need a note in the README, however, for those developers less familiar with Ring.
I see. Well if it can't be avoided that's that; it's trivial to work around anyway. A note in the docs would be nice.
Thanks for the quick response.
I came across the following oddity a few days ago: if you create two sets of routes, wrap them both individually with
wrap-json-body
and them combine them, the first set work fine, but the second getnil
as the request body.E.g. (using compojure)
POSTing json data to
/test1
causes the body to be printed to the terminal, whereas posting the exact same to/test2
just prints nil.I made a repo to test this at https://github.com/tgetgood/json-ring-test