I am trying to make a reverse proxy that will redirect HTTP packets to different hosts based on a tenant embedded in the URL.
The implementation is attached as a screenshot.
I get this error:
2022/04/05 12:31:01 http: proxy error: readfrom tcp **** http: invalid Read on closed Body
2022/04/05 12:31:01 http: superfluous response.WriteHeader call from net/http/httputil.(*ReverseProxy).defaultErrorHandler (reverseproxy.go:190)
If i don't reuse the proxy object, but rather spawn a new proxy each request everything works fine.
From my understanding the proxy object should be per host and not per request, as such i can keep reusing it for different requests. What am I missing?
I know that I need to protect these maps with a mutex but that is irrelevant at the moment.
Thanks,