Added streaming

This commit is contained in:
2024-03-22 14:37:21 +01:00
parent 1803bf7108
commit 17158235ea
3 changed files with 46 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import (
// Response is the interface for an HTTP response.
type Response interface {
Flush()
Header(key string) string
SetHeader(key string, value string)
Write([]byte) (int, error)
@ -18,6 +19,15 @@ type response struct {
http.ResponseWriter
}
// Flush flushes the response buffers to the client.
func (res response) Flush() {
flusher, ok := res.ResponseWriter.(http.Flusher)
if ok {
flusher.Flush()
}
}
// Header returns the header value for the given key.
func (res response) Header(key string) string {
return res.ResponseWriter.Header().Get(key)