summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/encode
diff options
context:
space:
mode:
authorKévin Dunglas <kevin@dunglas.fr>2023-04-27 01:44:01 +0200
committerGitHub <noreply@github.com>2023-04-26 19:44:01 -0400
commit1c9ea0113d007d57bb8f793ebe7a64a3dcad7bc7 (patch)
tree7f50b0cb2db708f1607436e83dd8b77c3c84046a /modules/caddyhttp/encode
parent2b04e09fa7830a2d24d863e448ebbdc51d537fbe (diff)
caddyhttp: Impl `ResponseWriter.Unwrap()`, prep for Go 1.20's `ResponseController` (#5509)
* feat: add support for ResponseWriter.Unwrap() * cherry-pick Francis' code
Diffstat (limited to 'modules/caddyhttp/encode')
-rw-r--r--modules/caddyhttp/encode/encode.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/caddyhttp/encode/encode.go b/modules/caddyhttp/encode/encode.go
index 8a6fc10..78d440e 100644
--- a/modules/caddyhttp/encode/encode.go
+++ b/modules/caddyhttp/encode/encode.go
@@ -299,6 +299,11 @@ func (rw *responseWriter) Close() error {
return err
}
+// Unwrap returns the underlying ResponseWriter.
+func (rw *responseWriter) Unwrap() http.ResponseWriter {
+ return rw.HTTPInterfaces
+}
+
// init should be called before we write a response, if rw.buf has contents.
func (rw *responseWriter) init() {
if rw.Header().Get("Content-Encoding") == "" && isEncodeAllowed(rw.Header()) &&