diff options
| author | Adnan Maolood <[email protected]> | 2021-02-17 11:44:11 -0500 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2021-02-17 11:44:13 -0500 |
| commit | a3c180439586c28740f0e23ab4e9fbd1704e7746 (patch) | |
| tree | a8c30b9534c7118923d840f5df4f0543192ee9cd /examples | |
| parent | fs: Reject potentially unsafe requests in ServeFile (diff) | |
| download | go-gemini-a3c180439586c28740f0e23ab4e9fbd1704e7746.tar.xz go-gemini-a3c180439586c28740f0e23ab4e9fbd1704e7746.zip | |
Move ResponseWriter.Flush to Flusher interface
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stream.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/examples/stream.go b/examples/stream.go index 0c302bd..5f3e2b5 100644 --- a/examples/stream.go +++ b/examples/stream.go @@ -39,6 +39,12 @@ func main() { // stream writes an infinite stream to w. func stream(w gemini.ResponseWriter, r *gemini.Request) { + flusher, ok := w.(gemini.Flusher) + if !ok { + w.Status(gemini.StatusTemporaryFailure) + return + } + ch := make(chan string) ctx, cancel := context.WithCancel(context.Background()) @@ -63,7 +69,7 @@ func stream(w gemini.ResponseWriter, r *gemini.Request) { break } fmt.Fprintln(w, s) - if err := w.Flush(); err != nil { + if err := flusher.Flush(); err != nil { cancel() return } |