Added streaming
This commit is contained in:
parent
fff5ce19b8
commit
ce209e79ed
3 changed files with 46 additions and 0 deletions
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue