[docs] add http2 example (#1000)

This commit is contained in:
田欧
2017-07-11 09:03:09 +08:00
committed by Bo-Yi Wu
parent 44da058aa0
commit 87fdff8f88
5 changed files with 97 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
package main
import (
"html/template"
"github.com/gin-gonic/gin"
)
var html = template.Must(template.New("https").Parse(`
<html>
<head>
<title>Https Test</title>
</head>
<body>
<h1 style="color:red;">Welcome, Ginner!</h1>
</body>
</html>
`))
func main() {
r := gin.Default()
r.SetHTMLTemplate(html)
r.GET("/welcome", func(c *gin.Context) {
c.HTML(200, "https", gin.H{
"status": "success",
})
})
// Listen and Server in https://127.0.0.1:8080
r.RunTLS(":8080", "./testdata/server.pem", "./testdata/server.key")
}