From 5056cb817d98b4b75af25abbe3eeb2ce991a887a Mon Sep 17 00:00:00 2001 From: Guilhem Lettron Date: Thu, 9 Nov 2023 00:38:54 +0100 Subject: [PATCH] feat(middleware-logging): implement http.Hijacker http.Hijacker is mandatory to forward websocket connexions Signed-off-by: Guilhem Lettron --- interceptor/middleware/loggingresponsewriter.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/interceptor/middleware/loggingresponsewriter.go b/interceptor/middleware/loggingresponsewriter.go index 9c893f1c..99619927 100644 --- a/interceptor/middleware/loggingresponsewriter.go +++ b/interceptor/middleware/loggingresponsewriter.go @@ -1,6 +1,9 @@ package middleware import ( + "bufio" + "errors" + "net" "net/http" ) @@ -46,3 +49,12 @@ func (lrw *loggingResponseWriter) WriteHeader(statusCode int) { lrw.statusCode = statusCode } + +// implements http.hijacker +func (lrw *loggingResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { + if hj, ok := lrw.downstreamResponseWriter.(http.Hijacker); ok { + return hj.Hijack() + } + + return nil, nil, errors.New("http.Hijacker not implemented") +}