hertz icon indicating copy to clipboard operation
hertz copied to clipboard

Hertz 在main.go中的启动建议

Open ilii opened this issue 5 months ago • 1 comments
trafficstars

func main() {
	// init dal
	// dal.Init()
	address := conf.GetConf().Hertz.Address
	h := server.New(server.WithHostPorts(address))

	registerMiddleware(h)

	// add a ping route to test
	h.GET("/ping", func(c context.Context, ctx *app.RequestContext) {
		ctx.JSON(consts.StatusOK, utils.H{"ping": "pong"})
	})

	router.GeneratedRegister(h)

	h.Spin()
}

希望 h.Spin() 这个Spin换个名字,这样的名字起多了,学习成本太高了,叫:run、start 更适合吧! 这样不用学习看到基本就知道是什么作用。希望未来,起名字不要这么随意!

ilii avatar Jun 07 '25 04:06 ilii