Go 1.7 HTTP/2 . push- 1.8 (. , - ).
Go 1.8 http.Pusher, net/http default ResponseWriter. Push-Push Push ErrNotSupported, (HTTP/1) ( ).
:
package main
import (
"io"
"log"
"net/http"
)
func main() {
http.HandleFunc("/pushed", func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "hello server push")
})
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if pusher, ok := w.(http.Pusher); ok {
if err := pusher.Push("/pushed", nil); err != nil {
log.Println("push failed")
}
}
io.WriteString(w, "hello world")
})
http.ListenAndServeTLS(":443", "server.crt", "server.key", nil)
}
push- Go 1.7 , golang.org/x/net/http2 .