Added streaming
This commit is contained in:
10
Response.go
10
Response.go
@ -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)
|
||||
|
Reference in New Issue
Block a user