From 3ef9787379bef0c48143535583b0f23233ffb56f Mon Sep 17 00:00:00 2001 From: James 'zofrex' Sanderson Date: Fri, 12 Dec 2025 12:05:05 +0000 Subject: [PATCH] tsweb: add Unwrap to loggingResponseWriter for ResponseController (#18195) The new http.ResponseController type added in Go 1.20: https://go.dev/doc/go1.20#http_responsecontroller requires ResponseWriters that are wrapping the original passed to ServeHTTP to implement an Unwrap method: https://pkg.go.dev/net/http#NewResponseController With this in place, it is possible to call methods such as Flush and SetReadDeadline on a loggingResponseWriter without needing to implement them there ourselves. Updates tailscale/corp#34763 Updates tailscale/corp#34813 Signed-off-by: James Sanderson --- tsweb/tsweb.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tsweb/tsweb.go b/tsweb/tsweb.go index 869b4cc8e..f6196174b 100644 --- a/tsweb/tsweb.go +++ b/tsweb/tsweb.go @@ -687,6 +687,10 @@ func (lg loggingResponseWriter) Flush() { f.Flush() } +func (lg *loggingResponseWriter) Unwrap() http.ResponseWriter { + return lg.ResponseWriter +} + // errorHandler is an http.Handler that wraps a ReturnHandler to render the // returned errors to the client and pass them back to any logHandlers. type errorHandler struct {