Hi All,
I am creating a proxy (or if I use ReverseProxy), I get the request and need to compute a hash function on it’s body. I want to calculate this hash in the same time as I redirect this message to its destination (assume body is large), I want it to start stream to the destination and meanwhile I calculate my hash function. So I cannot read all the body and start sending it only then.
But the body is io.ReadCloser and it cannot read it twice.
What can I do to still be able to resend the request and calculate the hash with minimal latency?
Thanks for the tip, I will try TeeReader. I am afraid it will reduce the performance of my “main” process. I need to redirect the message as fast as possible to the server, and now I will add writes to this critical path. Do you have maybe another idea that will not add latency to the first read (I can pay this latency in the second one if this possible).