Skip to content

Commit

Permalink
implement Flusher and Hijacker for codeCatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
mpl authored and traefiker committed Sep 13, 2019
1 parent df5f530 commit 24d084d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions middlewares/errorpages/error_pages.go
Expand Up @@ -194,6 +194,21 @@ func (cc *codeCatcher) WriteHeader(code int) {
cc.code = code
}

// Hijack hijacks the connection
func (cc *codeCatcher) Hijack() (net.Conn, *bufio.ReadWriter, error) {
if hj, ok := cc.responseWriter.(http.Hijacker); ok {
return hj.Hijack()
}
return nil, nil, fmt.Errorf("%T is not a http.Hijacker", cc.responseWriter)
}

// Flush sends any buffered data to the client.
func (cc *codeCatcher) Flush() {
if flusher, ok := cc.responseWriter.(http.Flusher); ok {
flusher.Flush()
}
}

type responseRecorder interface {
http.ResponseWriter
http.Flusher
Expand Down

0 comments on commit 24d084d

Please sign in to comment.