From 798ff53cc81508049c11f509313258501ec26aad Mon Sep 17 00:00:00 2001 From: htobenothing Date: Wed, 7 Mar 2018 23:06:30 +0800 Subject: [PATCH] add Pusher function for http2 server push --- response_writer.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/response_writer.go b/response_writer.go index 232f00aa..a45690af 100644 --- a/response_writer.go +++ b/response_writer.go @@ -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 +}