What would be a strategy to intercept writes to a http.ResponseWriter but keep all functionality of the original response writer? An example would be middleware that e.g. gzips or minifies any writes to a response writer. A contrived example would be: https://play.golang.org/p/PZxxLaWu5W
Is there a way to expose the hijacker functionality of the original responsewriter from the middleware responsewriter?
评论:
mwholt:
gohacker:That is essentially how Caddy does it. https://github.com/mholt/caddy/blob/696792781a5a8e9c70959b6c2de414d2700257e5/caddyhttp/gzip/gzip.go#L105-L163
Although I'm not thrilled with it either. :-/
manoharank:
