mirror of
https://github.com/labstack/echo.git
synced 2025-01-26 03:20:08 +02:00
Wrapped Flush, Hijack and CloseNotify functions in response.
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
5df84923dd
commit
cd1e235ccc
18
response.go
18
response.go
@ -1,7 +1,9 @@
|
|||||||
package echo
|
package echo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/labstack/gommon/color"
|
"github.com/labstack/gommon/color"
|
||||||
@ -37,6 +39,21 @@ func (r *Response) Write(b []byte) (n int, err error) {
|
|||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flush wraps response writer's Flush function.
|
||||||
|
func (r *Response) Flush() {
|
||||||
|
r.Writer.(http.Flusher).Flush()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hijack wraps response writer's Hijack function.
|
||||||
|
func (r *Response) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||||
|
return r.Writer.(http.Hijacker).Hijack()
|
||||||
|
}
|
||||||
|
|
||||||
|
// CloseNotify wraps response writer's CloseNotify function.
|
||||||
|
func (r *Response) CloseNotify() <-chan bool {
|
||||||
|
return r.Writer.(http.CloseNotifier).CloseNotify()
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Response) Status() int {
|
func (r *Response) Status() int {
|
||||||
return r.status
|
return r.status
|
||||||
}
|
}
|
||||||
@ -47,5 +64,6 @@ func (r *Response) Size() int64 {
|
|||||||
|
|
||||||
func (r *Response) reset(w http.ResponseWriter) {
|
func (r *Response) reset(w http.ResponseWriter) {
|
||||||
r.Writer = w
|
r.Writer = w
|
||||||
|
r.status = http.StatusOK
|
||||||
r.committed = false
|
r.committed = false
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user