This commit is contained in:
Lunny Xiao
2022-04-29 20:23:48 +08:00
committed by Jason Song
parent b91167b772
commit 7732392a96
16 changed files with 1801 additions and 0 deletions

View File

@ -5,6 +5,9 @@
package context
import (
"bufio"
"errors"
"net"
"net/http"
)
@ -84,6 +87,14 @@ func (r *Response) Before(f func(ResponseWriter)) {
r.befores = append(r.befores, f)
}
func (r *Response) Hijack() (net.Conn, *bufio.ReadWriter, error) {
if h, ok := r.ResponseWriter.(http.Hijacker); ok {
return h.Hijack()
}
return nil, nil, errors.New("unimplemented http.Hijacker ")
}
// NewResponse creates a response
func NewResponse(resp http.ResponseWriter) *Response {
if v, ok := resp.(*Response); ok {