Skip to content

Commit

Permalink
add Pusher function for http2 server push
Browse files Browse the repository at this point in the history
  • Loading branch information
htobenothing authored and appleboy committed Jun 20, 2018
1 parent caf3e35 commit bc20de4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions response_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ type ResponseWriter interface {

// Forces to write the http header (status code + headers).
WriteHeaderNow()

// get the http.Pusher for server push
Pusher()
}

type responseWriter struct {
Expand Down Expand Up @@ -112,3 +115,10 @@ func (w *responseWriter) CloseNotify() <-chan bool {
func (w *responseWriter) Flush() {
w.ResponseWriter.(http.Flusher).Flush()
}

func (w *responseWriter) Pusher() (pusher http.Pusher) {
if pusher, ok := w.ResponseWriter.(http.ResponseWriter).(http.Pusher); ok {
return pusher
}
return nil
}

0 comments on commit bc20de4

Please sign in to comment.