新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Gin教程:GinHTTP2server推送
?http.Pusher? 僅支持 ?go1.8+?

創(chuàng)新互聯(lián)建站專業(yè)為企業(yè)提供臨川網(wǎng)站建設(shè)、臨川做網(wǎng)站、臨川網(wǎng)站設(shè)計、臨川網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計與制作、臨川企業(yè)網(wǎng)站模板建站服務(wù),十余年臨川做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。
package main
import (
"html/template"
"log"
"github.com/gin-gonic/gin"
)
var html = template.Must(template.New("https").Parse(`
Https Test
Welcome, Ginner!
`))
func main() {
r := gin.Default()
r.Static("/assets", "./assets")
r.SetHTMLTemplate(html)
r.GET("/", func(c *gin.Context) {
if pusher := c.Writer.Pusher(); pusher != nil {
// 使用 pusher.Push() 做服務(wù)器推送
if err := pusher.Push("/assets/app.js", nil); err != nil {
log.Printf("Failed to push: %v", err)
}
}
c.HTML(200, "https", gin.H{
"status": "success",
})
})
// 監(jiān)聽并在 https://127.0.0.1:8080 上啟動服務(wù)
r.RunTLS(":8080", "./testdata/server.pem", "./testdata/server.key")
} 網(wǎng)站標題:創(chuàng)新互聯(lián)Gin教程:GinHTTP2server推送
本文地址:http://fisionsoft.com.cn/article/ccsihgi.html


咨詢
建站咨詢
