add Pusher function for http2 server push

This commit is contained in:
htobenothing 2018-03-07 23:06:30 +08:00 committed by Bo-Yi Wu
parent 87d536c001
commit 798ff53cc8

View File

@ -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 {
@ -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
}