mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-15 19:41:02 +00:00
middleware/errorhandler: Implement Hijacker so it works with ws proxy
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -78,3 +81,14 @@ func (i *errorInterceptor) Write(data []byte) (int, error) {
|
||||
}
|
||||
return len(data), nil
|
||||
}
|
||||
|
||||
// errorInterceptor also implements net.Hijacker, to let the downstream Handler
|
||||
// hijack the connection. This is needed by the app-mapper's proxy.
|
||||
func (i *errorInterceptor) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||
hj, ok := i.originalWriter.(http.Hijacker)
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("error interceptor: can't cast original ResponseWriter to Hijacker")
|
||||
}
|
||||
i.gotCode = true
|
||||
return hj.Hijack()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user