Browse Source

Wrap Hijack func

Volodymyr Tkach 2 years ago
parent
commit
f817aa780c
1 changed files with 13 additions and 1 deletions
  1. 13 1
      utils/http/logger/writer.go

+ 13 - 1
utils/http/logger/writer.go

@@ -1,6 +1,11 @@
 package logger
 package logger
 
 
-import "net/http"
+import (
+	"bufio"
+	"errors"
+	"net"
+	"net/http"
+)
 
 
 type ResponseWriter struct {
 type ResponseWriter struct {
 	http.ResponseWriter
 	http.ResponseWriter
@@ -9,6 +14,13 @@ type ResponseWriter struct {
 	Status  int
 	Status  int
 }
 }
 
 
+func (w *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
+	if h, ok := w.ResponseWriter.(http.Hijacker); ok {
+		return h.Hijack()
+	}
+	return nil, nil, errors.New("hijack not supported")
+}
+
 func (w *ResponseWriter) Write(b []byte) (int, error) {
 func (w *ResponseWriter) Write(b []byte) (int, error) {
 	if RollBarEnabled && !RollBarSkipStatusCodes.contain(w.Status) {
 	if RollBarEnabled && !RollBarSkipStatusCodes.contain(w.Status) {
 		w.Content = append(w.Content, b...)
 		w.Content = append(w.Content, b...)