I am trying to override the original body in conn, but it seems like I cannot figure out how to do that.
def create_stuff(conn) do
{:ok, body, _conn} = Plug.Conn.read_body(conn, length: 1_000_000)
json_body = Jason.decode!(body)
data = get_stuff_from_another_service(json_body)
new_data = merge_body_with_another_data(json_body, data)
# How can I update the original body of the connection?
conn = %{conn | ...: Jason.encode!(new_data)}
# After that I proxy the connection to another services
ReverseProxy.call(conn, [])
end
Is it possible to replace the initial body?