fix: golanglint

This commit is contained in:
Flc゛ 2023-04-26 22:37:48 +08:00
parent fe989b6a6f
commit 72838a5d2e

View File

@ -1075,6 +1075,9 @@ func (c *Context) SSEvent(name string, message any) {
// indicates "Is client disconnected in middle of stream" // indicates "Is client disconnected in middle of stream"
func (c *Context) Stream(step func(w io.Writer) bool) bool { func (c *Context) Stream(step func(w io.Writer) bool) bool {
w := c.Writer w := c.Writer
if _, ok := w.(http.CloseNotifier); !ok {
return false
}
clientGone := w.CloseNotify() clientGone := w.CloseNotify()
for { for {
select { select {
@ -1082,7 +1085,9 @@ func (c *Context) Stream(step func(w io.Writer) bool) bool {
return true return true
default: default:
keepOpen := step(w) keepOpen := step(w)
w.Flush() if flusher, ok := w.(http.Flusher); ok {
flusher.Flush()
}
if !keepOpen { if !keepOpen {
return false return false
} }