Skip to content

Commit ef64400

Browse files
committed
Merge pull request #70 from labstack/websocket
Wrapped Flush, Hijack and CloseNotify functions in response.
2 parents 5df8492 + cd1e235 commit ef64400

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

response.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package echo
22

33
import (
4+
"bufio"
45
"log"
6+
"net"
57
"net/http"
68

79
"github.com/labstack/gommon/color"
@@ -37,6 +39,21 @@ func (r *Response) Write(b []byte) (n int, err error) {
3739
return n, err
3840
}
3941

42+
// Flush wraps response writer's Flush function.
43+
func (r *Response) Flush() {
44+
r.Writer.(http.Flusher).Flush()
45+
}
46+
47+
// Hijack wraps response writer's Hijack function.
48+
func (r *Response) Hijack() (net.Conn, *bufio.ReadWriter, error) {
49+
return r.Writer.(http.Hijacker).Hijack()
50+
}
51+
52+
// CloseNotify wraps response writer's CloseNotify function.
53+
func (r *Response) CloseNotify() <-chan bool {
54+
return r.Writer.(http.CloseNotifier).CloseNotify()
55+
}
56+
4057
func (r *Response) Status() int {
4158
return r.status
4259
}
@@ -47,5 +64,6 @@ func (r *Response) Size() int64 {
4764

4865
func (r *Response) reset(w http.ResponseWriter) {
4966
r.Writer = w
67+
r.status = http.StatusOK
5068
r.committed = false
5169
}

0 commit comments

Comments
 (0)