main
This commit is contained in:
parent
ffa09a9337
commit
2d3be35c87
34
god.go
34
god.go
|
|
@ -1,7 +1,37 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"html/template"
|
||||
"log"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var html = template.Must(template.New("https").Parse(`
|
||||
<html>
|
||||
<head>
|
||||
<title>Https Test</title>
|
||||
<script src="/assets/app.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 style="color:red;">Welcome, Ginner!</h1>
|
||||
</body>
|
||||
</html>
|
||||
`))
|
||||
|
||||
func mains() {
|
||||
fmt.Println("hello 52.")
|
||||
r := gin.Default()
|
||||
r.Static("/assets", "./assets")
|
||||
r.SetHTMLTemplate(html)
|
||||
r.GET("/", func(c *gin.Context) {
|
||||
if pusher := c.Writer.Pusher(); pusher != nil {
|
||||
if err := pusher.Push("/assets/app.js", nil); err != nil {
|
||||
log.Panicf("Failed to push: %v", err)
|
||||
}
|
||||
}
|
||||
c.HTML(200, "https", gin.H{
|
||||
"status": "success",
|
||||
})
|
||||
})
|
||||
r.RunTLS(":8080", "./testdata/server.pem", "./testdata/server.key")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue