Read body doesn't bring any result if ReverseProxy plug used inside Phoenix
I have tinkered with integrating the ReverseProxy plug within a Phoenix app - using forward so that just a few selected endpoints would be proxied upstream.
However, I came across an issue where Plug's read_body/2 is being called earlier in the pipeline (inside Phoenix parsers), thus rendering the ReverseProxy call to read the body useless.
Any idea on a way to overcome this issue?
Spent a little time making this work in phoenix. read_body/2 has long since been called in phoenix. They key is to use body_params. Just call Poison.encode!(conn.body_params) rather than calling Conn.read_body(conn). (My actual change is to see if body_params exists and call Poison.encode!/1 if it does otherwise do the current code path using read_body/2.)
@baldmountain Thanks for looking into this! If you're willing, be sure to submit a PR with your changes. I'd love for you to get credit here. If you're unable, I'll definitely be sure to attribute you with the solution.
@slogsdon sure, I can make a PR. I'll have to implement it properly since I just hacked things together to make it work for my case. :)