1 Star 0 Fork 0

学习 / goxiaomi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.go 991 Bytes
一键复制 编辑 原始数据 按行查看 历史
haixb 提交于 2024-03-14 22:39 . elasticsearch
package main
import (
"github.com/gin-contrib/sessions"
cookie2 "github.com/gin-contrib/sessions/cookie"
"github.com/gin-gonic/gin"
"goxiaomi/models"
"goxiaomi/routers"
"html/template"
)
type Student struct {
Name string `json:"name,omitempty"`
Age int `json:"age,omitempty"`
}
func main() {
r := gin.Default() //创建默认对路由引擎
r.SetFuncMap(template.FuncMap{
"UnixToTime": models.UnixToTime,
"toInt": models.IntNoErr,
"countList": models.CountList,
"MbSubstr": models.MbSubstr,
})
r.LoadHTMLGlob("view/**/**/*")
r.Static("/static", "./static")
////创建基于cookie的存储引擎,secret11111 参数适用于加密的密钥
cookie := cookie2.NewStore([]byte("112233"))
//配置session的中间件,store是前面创建的存储引擎,我们可以替换成其他存储引擎
r.Use(sessions.Sessions("mysession", cookie))
routers.AdminRoutersInit(r)
routers.IndexRoutersInit(r)
routers.ApiRoutersInit(r)
r.Run("127.0.0.1:8001")
}
1
https://gitee.com/ppstudy_1/goxiaomi.git
git@gitee.com:ppstudy_1/goxiaomi.git
ppstudy_1
goxiaomi
goxiaomi
main

搜索帮助

53164aa7 5694891 3bd8fe86 5694891