Go HTTP/2请求,但不支持推送

Go HTTP/2请求,但不支持推送,go,http2,Go,Http2,我开始使用go http/2推送,但这些示例对我不起作用。 请求在http/2中(我可以在firefox中看到“Version:http/2.0”,我有一个扩展来判断服务器是否使用http/2)。 然而,类似于: http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { if pusher, ok := w.(http.Pusher); ok { // Push is supported.

我开始使用go http/2推送,但这些示例对我不起作用。 请求在http/2中(我可以在firefox中看到“Version:http/2.0”,我有一个扩展来判断服务器是否使用http/2)。 然而,类似于:

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    if pusher, ok := w.(http.Pusher); ok {
        // Push is supported.
        if err := pusher.Push("/app.js", nil); err != nil {
            log.Printf("Failed to push: %v", err)
        }
    } else {
      fmt.Println("Push not supported")
    }
    // ...
})
始终显示“不支持推送”。 有没有调试的提示


谢谢

别管了,我找到了,因为我用的是negroni:

如果我忽略了这个断言,不管怎样尝试推,我遇到了一个恐慌:2017-06-03_01:05:22.85073推CSS------------------2017-06-03_01:05:22.85087 2017/06/03 01:05:22 http2:恐慌服务172.18.0.1:43268:运行时错误:无效内存地址或零指针解引用2017-06-03_01:05:22.85088 goroutine 86[运行]:2017-06-03_01:05:22.85088 net/http.(*http2serverConn).runHandler.func1(0xc42000c038,0xc42015ffaf,0xc420133880)2017-06-03_01:05:22.85090/usr/local/ceral/go/1.8.3/libexec/src/net/http/h2_bundle.go:4604+0x190忽略断言保证不起作用。