Experiments: HTTP streaming render
This commit is contained in:
parent
e1eb4a1c01
commit
421793bfba
14
context.go
14
context.go
@ -375,6 +375,20 @@ func (c *Context) File(filepath string) {
|
|||||||
http.ServeFile(c.Writer, c.Request, filepath)
|
http.ServeFile(c.Writer, c.Request, filepath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Context) Stream(step func(w http.ResponseWriter)) {
|
||||||
|
w := c.Writer
|
||||||
|
clientGone := w.CloseNotify()
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-clientGone:
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
step(w)
|
||||||
|
w.Flush()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/************************************/
|
/************************************/
|
||||||
/******** CONTENT NEGOTIATION *******/
|
/******** CONTENT NEGOTIATION *******/
|
||||||
/************************************/
|
/************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user