My pseudo-code would look like this:
get "/something/:seed" do |env| res = HTTP::Client.get(url) env.response.status_code = res.status_code env.response.headers.merge! res.headers env.response.body = res.body_io? end
I’m basically implementing a reverse proxy for a single API endpoint. I want to pass the body from HTTP::Client with minimal CPU/memory/GC impact. Basically piping it as-is. Currently I am getting:
12 | env.response.body = res.body_io? ^--- Error: undefined method 'body=' for HTTP::Server::Response HTTP::Server::Response trace: src/routes/img.cr:12 env.response.body = res.body_io?
and am not really sure the best way to proceed. Using something external to crystal like nginx is not an option for reasons. Using kemal if that matters. The data being passed through is going to be binary and sometimes XML.