Radar · Go · Archive · Week 40 · Sep 29 – Oct 5, 2025
Deprecate ReverseProxy.Director in favor of ReverseProxy.Rewrite
Worth knowingstdlib
- What changed
net/http/httputil.ReverseProxy.Directoris now deprecated;ReverseProxy.Rewriteshould be used instead.NewSingleHostReverseProxywill continue to useDirectorfor compatibility.- Production impact
- The source does not say.
- Try it
- Create a
httputil.ReverseProxyand set itsRewritefield, then observe the deprecation warning in the compiler output. - Source
- github.com/golang/go/issues/73161
Understand it, then run it
net/http/httputil.ReverseProxy had a field called Director. That field let you change the request before it was sent to the target server. It was found to be insecure, so the Go team decided to mark it as deprecated. The replacement is a field called Rewrite. The old helper NewSingleHostReverseProxy still uses Director for backward compatibility, but new code should use Rewrite instead.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed