2020-07-08 10:09:59 +08:00
|
|
|
|
package main
|
|
|
|
|
|
2020-07-08 11:39:36 +08:00
|
|
|
|
import (
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
ruisUtil "github.com/mgr9525/go-ruisutil"
|
|
|
|
|
"gokins/comm"
|
|
|
|
|
"gokins/utils"
|
|
|
|
|
"html/template"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var testHTML = `
|
|
|
|
|
<html>
|
|
|
|
|
<head><title>{{AppName}}-测试</title></head>
|
|
|
|
|
<body>内容:{{.cont}}</body>
|
|
|
|
|
</html>
|
|
|
|
|
`
|
2020-07-08 10:09:59 +08:00
|
|
|
|
|
|
|
|
|
func main() {
|
2020-07-08 11:39:36 +08:00
|
|
|
|
comm.Gin = gin.Default()
|
|
|
|
|
comm.Gin.FuncMap = template.FuncMap{
|
|
|
|
|
"AppName": func() string {
|
|
|
|
|
return "mine app"
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
comm.Gin.Any("/ping", func(c *gin.Context) {
|
|
|
|
|
data := ruisUtil.NewMap()
|
|
|
|
|
data.Set("cont", "你好啊world!")
|
|
|
|
|
utils.RenderHTML(c, testHTML, data)
|
2020-07-08 10:09:59 +08:00
|
|
|
|
})
|
2020-07-08 11:39:36 +08:00
|
|
|
|
comm.Gin.Run(":8050")
|
2020-07-08 10:09:59 +08:00
|
|
|
|
}
|