Skip to content

Commit

Permalink
feat(middleware-logging): implement http.Hijacker
Browse files Browse the repository at this point in the history
http.Hijacker is mandatory to forward websocket connexions

Signed-off-by: Guilhem Lettron <[email protected]>
  • Loading branch information
guilhem committed Nov 8, 2023
1 parent 2fa0be3 commit 5056cb8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions interceptor/middleware/loggingresponsewriter.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package middleware

import (
"bufio"
"errors"
"net"
"net/http"
)

Expand Down Expand Up @@ -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")
}

0 comments on commit 5056cb8

Please sign in to comment.