u
This commit is contained in:
1 parent
755fc20c9a
commit
a57070f860
9 files changed
+557
-93
No files matched your search
@@ -1,42 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"cn/oneao/base-go/biz/router/middleware"
|
||||
"cn/oneao/base-go/config"
|
||||
"cn/oneao/base-go/db"
|
||||
"cn/oneao/base-go/log"
|
||||
"cn/oneao/base-go/utils/idgen"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app/server"
|
||||
"github.com/cloudwego/hertz/pkg/common/hlog"
|
||||
"github.com/hertz-contrib/requestid"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
// 初始化雪花id
|
||||
options := idgen.NewIdGeneratorOptions(config.App.Snowflake.WorkerID)
|
||||
idgen.SetIdGenerator(options)
|
||||
|
||||
// 初始化数据库
|
||||
db.InitDB()
|
||||
// 日志
|
||||
log.InitLog()
|
||||
|
||||
h := server.Default(
|
||||
server.WithBasePath(config.App.Server.BaseUrl),
|
||||
server.WithHostPorts(config.App.Server.Port),
|
||||
)
|
||||
|
||||
// 请求 id
|
||||
// 全局中间件
|
||||
h.Use(requestid.New())
|
||||
|
||||
log.InitLog()
|
||||
|
||||
type User struct {
|
||||
Name string
|
||||
Age int
|
||||
}
|
||||
|
||||
u := User{"tom", 20}
|
||||
|
||||
hlog.Info(u)
|
||||
h.Use(middleware.Log())
|
||||
|
||||
register(h)
|
||||
h.Spin()
|
||||
|
||||
Reference in new issue
Block a user