initial commit
This commit is contained in:
27
backend/internal/api/flush_writer.go
Normal file
27
backend/internal/api/flush_writer.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type flushWriter struct {
|
||||
w http.ResponseWriter
|
||||
f http.Flusher
|
||||
}
|
||||
|
||||
func (fw *flushWriter) Write(p []byte) (n int, err error) {
|
||||
// Write Data
|
||||
n, err = fw.w.Write(p)
|
||||
if err == nil && fw.f != nil {
|
||||
fw.f.Flush()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func newFlushWriter(w http.ResponseWriter) *flushWriter {
|
||||
flusher, _ := w.(http.Flusher)
|
||||
return &flushWriter{
|
||||
w: w,
|
||||
f: flusher,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user