summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/fileserver/staticfiles.go
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/fileserver/staticfiles.go
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/fileserver/staticfiles.go')
-rw-r--r--modules/caddyhttp/fileserver/staticfiles.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/caddyhttp/fileserver/staticfiles.go b/modules/caddyhttp/fileserver/staticfiles.go
index 0459b3a..2b5cc3d 100644
--- a/modules/caddyhttp/fileserver/staticfiles.go
+++ b/modules/caddyhttp/fileserver/staticfiles.go
@@ -636,6 +636,12 @@ func (wr statusOverrideResponseWriter) WriteHeader(int) {
wr.ResponseWriter.WriteHeader(wr.code)
}
+// Unwrap returns the underlying ResponseWriter, necessary for
+// http.ResponseController to work correctly.
+func (wr statusOverrideResponseWriter) Unwrap() http.ResponseWriter {
+ return wr.ResponseWriter
+}
+
// osFS is a simple fs.FS implementation that uses the local
// file system. (We do not use os.DirFS because we do our own
// rooting or path prefixing without being constrained to a single