Files
workspace/code/allapp/allapp-go/main.go
T
2026-01-13 22:18:01 +08:00

42 lines
769 B
Go

package main
import (
"allapp/biz/router/middleware"
"allapp/conf"
"allapp/db"
"allapp/logx"
"allapp/utils/idgen"
"allapp/utils/jwtx"
"github.com/cloudwego/hertz/pkg/app/server"
"github.com/hertz-contrib/requestid"
)
func main() {
// 初始化雪花id
options := idgen.NewIdGeneratorOptions(conf.GetConf().Snowflake.WorkerID)
idgen.SetIdGenerator(options)
// 数据库
db.InitDB()
// 日志
logx.InitLog()
// jwt
jwtx.InitJwt()
h := server.Default(
server.WithBasePath(conf.GetConf().Server.BaseUrl),
server.WithHostPorts(":"+conf.GetConf().Server.Port),
)
// 全局中间件
h.Use(requestid.New())
h.Use(middleware.Log())
h.Use(middleware.Error())
h.Use(middleware.Auth())
h.Use(middleware.RefreshActive())
register(h)
h.Spin()
}