Skip to content

Commit

Permalink
add hijack function support to ResponseWriter struct
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaynanavare committed Sep 3, 2024
1 parent 94e7143 commit 9237baa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions go/httpmetrics/response_writer.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package httpmetrics

import (
"bufio"
"net"
"net/http"
"sync"
)
Expand Down Expand Up @@ -31,6 +33,15 @@ func (rw *ResponseWriter) WriteHeader(statusCode int) {
rw.w.WriteHeader(statusCode)
}

func (rw *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
hj, ok := rw.w.(http.Hijacker)
if !ok {
return nil, nil, http.ErrNotSupported
}

return hj.Hijack()
}

func (rw *ResponseWriter) Write(data []byte) (int, error) {
// rw.w.WriteHeader(rw.code)
if rw.code >= http.StatusInternalServerError {
Expand Down

0 comments on commit 9237baa

Please sign in to comment.