This method is called to parse the request body so we can create our params object for the actions. The current implementation potentially creates 2 IO instances on each request, and the way the method reads is a little confusing. On top of that, it's not documented why it works like this....
It seems the idea may be that instead of having to manually rewind the body just so you can call params more than once in an action, it's setting the request body back and ensuring that it's an IO::Memory and not some other IO object.
This method is called to parse the request body so we can create our
params
object for the actions. The current implementation potentially creates 2 IO instances on each request, and the way the method reads is a little confusing. On top of that, it's not documented why it works like this....https://github.com/luckyframework/lucky/blob/2e929598148caa4c7ee8bca143b02aab84c27e32/src/lucky/request_body_reader.cr#L8-L12
It seems the idea may be that instead of having to manually rewind the body just so you can call params more than once in an action, it's setting the request body back and ensuring that it's an
IO::Memory
and not some other IO object.This might be a cleaner solution:
And then just document what it's doing.