Commit e79a8885 authored by Tw's avatar Tw

let middleware.responseRecorder be a http.Hijacker

Signed-off-by: default avatarTw <tw19881113@gmail.com>
parent 01aca02e
package middleware
import (
"bufio"
"errors"
"net"
"net/http"
"time"
)
......@@ -48,3 +51,12 @@ func (r *responseRecorder) Write(buf []byte) (int, error) {
}
return n, err
}
// Hijacker is a wrapper of http.Hijacker underearth if any,
// otherwise it just returns an error.
func (r *responseRecorder) Hijack() (net.Conn, *bufio.ReadWriter, error) {
if hj, ok := r.ResponseWriter.(http.Hijacker); ok {
return hj.Hijack()
}
return nil, nil, errors.New("I'm not a Hijacker")
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment