1 Star 0 Fork 0

lrobin / dl-lab

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
router.go 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
lrobin 提交于 2023-04-13 21:16 . Add gsm/k8s components
// Copyright 2023 Leo <lipf160627@163.com>. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package healthy
import (
"net/http"
"time"
"github.com/gin-gonic/gin"
)
func routerInit(g *gin.Engine) {
installMiddleware(g)
installController(g)
}
func installMiddleware(g *gin.Engine) {
}
func installController(g *gin.Engine) {
// user RESTful resource
healthy := g.Group("/healthy")
{
healthy.GET("/readiness", func(c *gin.Context) {
if healthyIsReady() {
c.JSON(http.StatusOK, gin.H{})
}
})
healthy.GET("/liveness", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{})
})
}
}
func NewAndRun() error {
// router := gin.Default()
// 不用 gin.Logger(),不需要记录log
router := gin.New()
router.Use(gin.Recovery())
routerInit(router)
server := &http.Server{
Addr: ":9000",
Handler: router,
ReadTimeout: 5 * time.Second,
WriteTimeout: 5 * time.Second,
}
server.ListenAndServe()
return nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/lrobin/dl-lab.git
git@gitee.com:lrobin/dl-lab.git
lrobin
dl-lab
dl-lab
v1.0.2

搜索帮助

344bd9b3 5694891 D2dac590 5694891